terbine9287
no leída,7 jul 2009, 10:30:47 p.m.7/7/2009Accede para responder al autor
Accede para reenviar el mensaje
No tienes permiso para borrar mensajes de este grupo
Mostrar el mensaje original
Las direcciones de correo electrónico son anónimas para este grupo, o bien, necesitas un permiso que te permita visualizar las direcciones de correo electrónico de los miembros a fin de ver el mensaje original
para 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