0
陣 「 - [NSMutableArray的insertObject:atIndex:]:嘗試在0插入無對象」Xcode中 - 添加UIImages從RSS提要URL問題
如果我使用硬編碼路徑( '路徑'代碼)它正確地添加圖像。當我從RSS提要檢索相同的URL時,它不起作用(上面的錯誤)。
我試着用一個簡單的等式檢查來檢查URL,它表明它們不相等,雖然它們在調試器輸出中看起來如此。
任何洞察內存管理也將是有幫助的。我來自Flash的工作世界和noob到xcode(抱歉)。我知道我需要停止內存管理思想作爲一種事後...
-
- (void)viewDidLoad
{
[super viewDidLoad];
[self prepareGalleryLoad]; //sets up coverflow, waiting for data
NSString *xmlpath = @"http://mydomain.com/gallery3/index.php/rss/feed/gallery/album/12";
xmlreader = [[XMLReader alloc] init];
[xmlreader parseXMLFileAtURL:xmlpath];
NSMutableArray *imagearray = [[NSMutableArray alloc]init]; //array of images
NSMutableArray *imagearraycaptions = [[NSMutableArray alloc]init]; //array of captions for images
NSString *path;
NSString *pathfromrss;
UIImage *tempimage;
for (int y = 0; y < [xmlreader.stories count]; y++){
[imagearraycaptions addObject:[[xmlreader.stories objectAtIndex:y] objectForKey:@"title"]];
path = @"http://mydomain.com/gallery3/var/resizes/College-of-Nursing-and-Health-Studies/health10.jpg?m=1299713266";
pathfromrss = [NSString stringWithFormat:@"%@",[[xmlreader.stories objectAtIndex:y] objectForKey:@"link"]];
//DIAGNOSTIC check of path vs path temp.
if (path == pathfromrss){
NSLog(@"path is equal");
}else{
NSLog(@"path is not equal");
NSLog(@"%@",path);
NSLog(@"%@",pathfromrss);
}
//END DIAGNOSTIC path check
tempimage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:path]]];
//tempimage is NIL when using "pathfromrss", works fine with "path"
if(tempimage){
[imagearray addObject:tempimage];
}
}
coverstext = imagearraycaptions; //coverflow uses this
covers = imagearray; //coverflow uses this
[self finishGalleryLoad];
}