Unsolved MATTER with data core in iOS iPhone App -


i tried best solve problem keep getting following error:

-[__nscfconstantstring ling]: unrecognized selector sent instance 0x12f80b0

what trying add line core data , table view text alertview, fire alertview , user put name of new language, text in alertview saved core data , added table view when user click save.

in table view, relevant code:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];      if(cell == nil){         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];     }      languages *languagesdict = (languages *)[languagesarray objectatindex:indexpath.row];      cell.textlabel.text = [languagesdict ling];     return cell; } 

and in alertview code when "save" button clicked:

  - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex {     if (buttonindex == 1)     {         nsstring *temptext = [alertview textfieldatindex:0].text;         if(!languagesarray)         {             languagesarray = [[nsmutablearray alloc]init];         }          [languagesarray insertobject:temptext atindex:0];         nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0];         [self.tableview insertrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic];         languages *languagesdict = [nsentitydescription insertnewobjectforentityforname:@"languages" inmanagedobjectcontext:_managedobjectcontext];         [languagesdict setling:temptext];         nserror *error = nil;         if (![_managedobjectcontext save:&error])         {         }     }   } 

can tell me wrong thing doing??

you're inserting nsstring objects languagesarray.

when try , extract objects out, in line:

languages *languagesdict = (languages *)[languagesarray objectatindex:indexpath.row];  

you're casting nsstring objects (for reason) languages objects. try call ling method on object you've fetched.

but ling method doesn't exist in nsstring, that's how you're getting run-time crash , error message.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -