terbine9287
necitită,7 iul. 2009, 22:30:4707.07.2009Conectați-vă pentru a-i răspunde autorului
Conectați-vă pentru a redirecționa
Nu aveți permisiunea de a șterge mesaje din acest grup
Adresele de e-mail sunt anonime pentru acest grup sau este necesară permisiunea de a vedea adresele de e-mail ale membrilor pentru a afișa mesajul inițial
– iPhone Application Development Auditors
I have looked at the Flicker sample code for hints on getting the
threads to work in presence 3 but I am a little stumped. I guess this
is a question regarding using threads properly. My goal is that I want
to retrieve the images, etc for a list of user names when the program
starts up and show a little progress indicator when doing so, so that
the program doesn't hang. I've been having some issues with doing this
and I have found that this is difficult to debug. More specifically,
in my PersonListViewController, I have...
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self showLoadingIndicators];
[self beginLoadingData];
}
- (void)beginLoadingData {
for (int i = 0; i < [userNamesArray count]; i++) {
NSString *currentUser = [userNamesArray objectAtIndex:i];
UserInfoLoadingOperation *operation = [[UserInfoLoadingOperation
alloc] initWithTwitterUser:currentUser target:self action:@selector
(didFinishLoadingWithResult:)];
[operationQueue addOperation:operation];
[operation release];
}
}
- (void)didFinishLoadingWithResult:(NSDictionary *)result {
Person *p = [[Person alloc] init];
p.userName = [result objectForKey:@"user"];
NSString *string = [result objectForKey:@"url"];
NSURL *url = [NSURL URLWithString:string];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [[UIImage alloc] initWithData:data];
p.img = image;
[personListArray addObject:p];
[p release];
[self.tableView reloadData];
}
However, in my UserInfoLoadingOperation class, I don't believe that
anything is every retrieved. If I put a break point right before it
gets added to the queue, it shows that everything is null except for
the user name, which is what I passed in to begin with.
Additionally, I get this error which makes the program not even run.
*** Terminating app due to uncaught exception 'NSRangeException',
reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'
I cannot place any break points within my UserInfoLoadingOperation
class because I get that error before I get a chance to look at it, so
I'm assuming the problem lies before that somewhere? Am I doing
something fundamentally wrong or what? I'm a bit confused and would
appreciate any advice.
Thanks