Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-13-2011, 03:05 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 32
mr curious is on a distinguished road
Default Parse XML attribute to NSInteger

Hey all,

I have an app which is reading from an XML file and saving the info in core data.

In my one entity Statement I have an an attribute accNum of type Integer and a few others of type Decimal.

For the Decimal attribute I'm saving them to core data as follows:

Code:
statement = (Statements *)[NSEntityDescription insertNewObjectForEntityForName:@"Statement" inManagedObjectContext:appDelegate.managedObjectContext];

[statement setBalanceOpen: [NSDecimalNumber decimalNumberWithDecimal:[[attributeDict objectForKey:@"balance_open"] decimalValue]]];
However I'm struggling to save the Integer to the core data attribute.
Any help please?

Thanks
mc

Last edited by mr curious; 09-13-2011 at 03:08 AM.
mr curious is offline   Reply With Quote
Old 09-13-2011, 09:10 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Have you tried using NSNumber?

Code:
[NSNumber numberWithInt:[[attributeDict objectForKey:@"int_key"] intValue]]
Then you can set your core data attribute with this.
smithdale87 is offline   Reply With Quote
Old 09-14-2011, 02:27 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 32
mr curious is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Have you tried using NSNumber?

Code:
[NSNumber numberWithInt:[[attributeDict objectForKey:@"int_key"] intValue]]
Then you can set your core data attribute with this.
I tried that, it gave me an error trying to parse an NSNumber to an NSDecimalNumber or something like that. I changed the type of the attribute and managed to get it to work.

Thanks
mc
mr curious is offline   Reply With Quote
Reply

Bookmarks

Tags
core data, nsinteger, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 402
9 members and 393 guests
7twenty7, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0