This is the problem code:
NSURL *url = [NSURL URLWithString:@"http://photostiubhart.comoj.com/ReadGallery/stiubhart1readgallery.php"];
NSError* error;
NSString* sizeString = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
double myDouble = [sizeString doubleValue];
int myInt = (int)(myDouble + (myDouble>0 ? 0.5 : -0.5));
//Create an array to hold the URLS
NSMutableArray *myURLS;
//Initialize the array with nil
myURLS = [[NSMutableArray alloc] init];
NSLog(@"Here1");
//Add all the URLs from the server to the array
for (int i = 0; i <= myInt; i++){
NSString *tempString = [[NSString alloc] initWithFormat : @"http://photostiubhart.comoj.com/GalleryImages/%dstiubhart1.jpg", i];
[myURLS addObject: [NSURL URLWithString:tempString]];
[tempString release];
}
myPhotos = [[NSMutableArray alloc] init];
for(int i = 0; i < myInt; i++){
[myPhotos addObject:[myURLS objectAtIndex:i]];
}
It gives the error:
2011-06-21 22:20:47.167 CHARLIE[666:207] -[NSURL length]: unrecognized selector sent to instance 0x70418c0
This is what the code does (at least supposed to):
- Generate an integer from the contents of the URL ("4").
- Use the integer in the for loops to add objects to arrays.
Can anyone tell me whats wrong here?
Thanks a lot,
Jack
lengthmessage to an NSURL object. There are no calls tolengthin your code. Can you post more about the error, or more of your code in this context?myDouble? the loops are testing slightly different conditions. it looks like you just wantmyPhotos = [NSMutableArray arrayWithArray:myURLS]. can you determine which line is giving you that error? (it's indicative of over released objects or inappropriate casting)