iphone - MBProgressHUD altering data output? -


i'm trying use mbprogresshud show loading animation while i'm accessing information smooth out process of going uitableview listing uiwebview has detailed information of item selected. if call [self fetchplayer]; without using mbprogresshud have no issues , works fine albeit without animation. if call [self loadinganimation]; half works. first time select uitableview loads correctly every time, if go , select same or different item quite null values playerdetails items. i'm not sure mbprogresshud method doing cause here code. nslog displaying correct information - main class calling 2 methods not output correctly.

- (void)loadinganimation {  // hud dispable input on view (use higest view possible in view hierarchy)     hud = [[mbprogresshud alloc] initwithview:self.navigationcontroller.view];      // add hud screen     [self.navigationcontroller.view addsubview:hud];      hud.labeltext = @"loading";      // show hud while provided method executes in new thread  [hud showwhileexecuting:@selector(fetchplayer) ontarget:self withobject:nil animated:yes]; }   - (void)fetchplayer {  nsmanagedobjectcontext *pcontext = [[appcontroller sharedappcontroller] managedobjectcontext];   nsfetchrequest *pfetch = [[nsfetchrequest alloc] init];   nsentitydescription *pentity = [nsentitydescription entityforname:@"players"               inmanagedobjectcontext:pcontext];  [pfetch setentity:pentity];   nspredicate *ppredicate = [nspredicate predicatewithformat:@"playerid=%@", [playernews playerid]];  [pfetch setpredicate:ppredicate];   nserror *perror;  nsarray *plist = [pcontext executefetchrequest:pfetch error:&perror];   playerdetails = [plist objectatindex:0];   nslog(@"%@ %@ %@ %@ %@", [playernews playerid],          [playerdetails valueforkey:@"playerfirstname"],         [playerdetails valueforkey:@"playerlastname"],         [playerdetails valueforkey:@"position"],         [playerdetails valueforkey:@"dateofbirth"]);   [pfetch release];   nsmanagedobjectcontext *context = [[appcontroller sharedappcontroller] managedobjectcontext];   nsfetchrequest *fetch = [[nsfetchrequest alloc] init];   nsentitydescription *entity = [nsentitydescription entityforname:@"teams"              inmanagedobjectcontext:context];  [fetch setentity:entity];   if (![playerdetails valueforkey:@"team"]) {   team = [playerdetail team];  } else {   team = [playerdetails valueforkey:@"team"];   }  nspredicate *predicate = [nspredicate predicatewithformat:@"team=%@", team];   [fetch setpredicate:predicate];   nserror *error;  nsarray *list = [context executefetchrequest:fetch error:&error];   playerteam = [list objectatindex:0];   [fetch release]; } 

this seems @ least problem threading. sharing context across multiple threads fetchplayer executed in background thread mbprogresshud.

create new context in background thread , make sure nsmanagedobjects not shared across threads.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -