我有兩種方法。從第一種方法我發送數組到第二種方法。在我的第一個方法中,[數組數]值是2.但是在seconf方法中,值是1.但是它們在兩種方法中都應該是相同的。我知道這是一個愚蠢的錯誤。但我不完全明白我犯了錯誤的地方。陣列計數錯誤
第一種方法:
-(void)uploadOverlayManually: (NSMutableArray *)path{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"Array count #1: %d",[path count]);
for (int i =0; i < [path count]; i++) {
imagePath = [path objectAtIndex:i];
NSString *infoPath = [[imagePath stringByDeletingPathExtension] stringByAppendingPathExtension:@"info"];
NSData *infoData = [[NSMutableData alloc] initWithContentsOfFile:infoPath];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:infoData];
MediaInformation *currentInfo = [unarchiver decodeObjectForKey:@"info"];
[unarchiver finishDecoding];
UIImage *baseImage = [UIImage imageWithContentsOfFile:imagePath];
NSData *data = [root addImageOverlay:baseImage withInfo:currentInfo andPath:imagePath];
[data writeToFile:imagePath atomically:YES];
fileUpload = [[NSMutableArray alloc] init];
[fileUpload addObject:imagePath];
}
[self upload:fileUpload];
}
第二種方法:
-(void)upload:(NSArray*)filePaths{
if (![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] linkFromController:root]; //root
}
NSLog(@"Array count #2: %d",[filePaths count]);
}