How do I concat a string + int and match it to an item in an NSArray?
Heres my Array.
NSArray *arrayData = [[NSArray a开发者_开发百科lloc] initWithObjects:@"1 days", @"7 days",
@"14 days", @"28 days", @"1 months", @"2 months",
@"3 months", @"4 months", @"6 months", @"1 years",
@"2 years", @"once", nil];
Heres my NSString and my integer.
int interval = 2;
NSString *itype = @"years";
I need to join both the integer + a space + the NSString and match it with the item in the array and get the index number of the array so I can pick the same index from another NSArray.
How do i do this ?
To join the string and integer:
NSString* yearString = [NSString stringWithFormat:@"%d %@", interval, itype];
And to search the array:
[array indexOfObject:yearString];
精彩评论