iphone - Getting string from NSManagedObject -



iphone - Getting string from NSManagedObject -

when seek string value nsmanagedobject, this

<entity: 0x1e043140> (entity: entity; id: 0x1e041c30 <x-coredata://8f48c331-b879-47b4-b257-4802a13ed12c/entity/p4> ; data: { number = "<uitextfield: 0x1d8b7cc0; frame = (159 183; 161 30); text = 'test'; clipstobounds = yes; opaque = no; autoresize = rm+bm; gesturerecognizers = <nsarray: 0x1d8b3c10>; layer = <calayer: 0x1d892a30>> : "; })

how string (it's text = 'test';)

i object using this

nsstring *rowvalue = [self.fetchedresultscontroller objectatindexpath:indexpath];

ok, nsmanaged object , sets uitableview cell string

nsmanagedobject *object = [self.fetchedresultscontroller objectatindexpath:indexpath]; cell.textlabel.text = [[object valueforkey:@"number"] description];

the reason it's showing because, can see, getting it's description. can't find property homecoming text value, know how? thanks.

i assume error occurs when store value in managed object. perhaps like

[myobject setvalue:[atextfield description] forkey:@"number"]

instead of storing text field's text contents:

[myobject setvalue:[atextfield text] forkey:@"number"]

update: write in comment, managed object values stored as

nsstring *string = [nsstring stringwithformat:@"%@ : %@", self.numtext, self.comtext]; [newmanagedobject setvalue:string forkey:@"number"];

but %@ format uitextfield itself expanded text fields description, not text contents. hence string looks like

"<uitextfield: 0x1d8b7cc0; frame = (159 183; 161 30); text = 'test'; .... "

and string stored "number" attribute in managed object. should utilize next code instead:

nsstring *string = [nsstring stringwithformat:@"%@ : %@", self.numtext.text, self.comtext.text]; [newmanagedobject setvalue:string forkey:@"number"];

note have delete old database when testing rid of existing wrong entries.

iphone ios objective-c core-data nsmanagedobject

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -