[Solved] How to append parameters to string in Objective C?


I’m guessing that the string you put at the beginning is the desired output.

In which case your method should be something like…

- (NSString *)parameterStringWithWidth:(NSString *)width
                                aspect:(NSInteger)aspect
                                   rim:(NSInteger)rim
                                season:(NSString *)season
                               pattern:(NSString *)pattern
                                  time:(NSInteger)time
{
    return [NSString stringWithFormat:@"getTyreLabels?width=m%@&aspect=%ld&rim=%ld&season=%@&time=%ld", width, (long)aspect, (long)rim, season, (long)time];
}

That will return the string. Not the URL but you should be able to get the point from this.

Note the way the method name is constructed. It makes it MUCH easier to call it from somewhere else as you can see what each parameter is relating to.

NSString *theString = [self parameterStringWithWidth:@"125.00" aspect:25 rim:13 season:@"SU" pattern:@"" time:269742091];

This will result in theString being the value you put in your question.

2

solved How to append parameters to string in Objective C?