ios - Unable to fetch the data from Core Data file -
ios - Unable to fetch the data from Core Data file -
when fetch record core info returns null value...i don't know problem...
when check in nslog
shows this:
"<ad: 0x979fb30> (entity: ad; id: 0x9799470 <x-coredata://b3aa111f-8307-4a16-b898- 403a804dfdfb/ad/p22> ; data: <fault>)", "<ad: 0x979fd70> (entity: ad; id: 0x9799480 <x-coredata://b3aa111f-8307-4a16-b898- 403a804dfdfb/ad/p23> ; data: <fault>)
here code. returned core info functions in separate class called dbmanager.
- (void)viewdidload { dbmanager *manager=[[dbmanager alloc]init]; self.fetchedrecordsarray = [manager fetchallads]; [self.shoppingtbl reloaddata]; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { homecoming 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { homecoming [self.fetchedrecordsarray count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"shoppingcart"; shoppingcart *cell = (shoppingcart*)[tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; cell.backgroundcolor=[uicolor clearcolor]; ad=[self.fetchedrecordsarray objectatindex:indexpath.row] cell.addesc.text = ad.data; cell.adid.text=[nsstring stringwithformat:@"%lu", (long)[ad.adid integervalue]]; cell.adstatus.text=[nsstring stringwithformat:@"%@",ad.state]; homecoming cell; }
the entity name called ad. contains adid,state,data.
in table view shows null value strings , 0 numbers..
i recommend abandon fetchedrecordsarray
, encompass nsfetchedresultscontroller
. designed work core info , table views.
this eliminate problem have , result in much more robust , scalable code. displaying 100.000s ads way without problem.
one more hint, i.e. might want check beforehand: quite perchance did not save info correctly. looks saved each record [managedobjectcontext save:&error]
after created, perhaps did not correctly after populating state, data. way check enumerate array elements , nslog
bits of info check if there.
ios uitableview core-data
Comments
Post a Comment