Reputation: 5
I have NSString*url
,and i want to combine with NSArray of number to load the picture ,i struggle for many days still doesn't work anyone know how to do it
p.s I want to replace NSString %@ with number of array
This is my NSString *url = http://flicksbank.console360.net/images/%@/default.jpg
And this is my number from NSArray :
(
42,
47,
56,
65,
97,
128,
277,
278,
312,
313,
518,
522,
523,
526
),
(
42,
89,
522
),
(
89,
312,
313
),
(
89,
522
),
(
91,
317
),
(
98
),
(
317,
518,
523,
525,
526
),
(
329
),
(
332
)
Upvotes: 0
Views: 46
Reputation: 1885
you can reach numbers with two for loops:
for(NSArray *numbers in yourMainArray)
{
for(NSNumber *n in numbers)
{
NSString *urlString = [NSString stringWithFormat:@"http://flicksbank.console360.net/images/%d/default.jpg", [n intValue]];
}
}
or more general solution for NSString
and NSNumber
for(NSArray *numbers in yourMainArray)
{
for(id n in numbers)
{
if([n isKindOfClass:[NSNumber class]])
{
NSString *urlString = [NSString stringWithFormat:@"http://flicksbank.console360.net/images/%d/default.jpg", [n intValue]];
}
if([n isKindOfClass:[NSString class]])
{
NSString *urlString = [NSString stringWithFormat:@"http://flicksbank.console360.net/images/%@/default.jpg", n];
}
}
}
Upvotes: 1
Reputation: 3008
you have nested array , if you want to display images with all those number you have to loop through both arrays.
for(NSArray* mainArray in firstArray){
for(NSString *number in mainArray){
NSLog(@"http://flicksbank.console360.net/images/%@/default.jpg",number);
}
}
Main array will be your object that you have logged.
Upvotes: 0