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 11-30-2011, 07:20 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Location: Sydney, Australia
Posts: 13
Kiwi77 is on a distinguished road
Question XML into NSMutableArray

Hi everyone,

I've searched the internet and am still having problems implementing XML into my project. At the moment I can set up an array using NSMutableArray and that works find. However all the data is stored in the AppDelegate.m.

Heres how I add entries into the array.

Code:
    ebooks_list = [NSMutableArray arrayWithCapacity:20];
    
    //First entry
    
    //Set var first
    ebooks *ebook;
    
    //Entry    
    ebook = [[ebooks alloc] init]; 
    ebook.isbn =@"0000000000000"; 
    ebook.title =@"Book Title"; 
    ebook.author =@"Author"; 
    ebook.disc =@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam at sagittis mi. Donec consequat, nulla a rutrum posuere, ante ligula egestas erat, non bibendum magna risus non mauris. Sed scelerisque ligula metus, vel sodales nulla. Fusce elementum dolor in mi aliquam laoreet. Morbi a justo ullamcorper nisi eleifend pulvinar ac vitae tortor. Cras sit amet eros urna. Pellentesque eget turpis vitae ante facilisis consectetur. Curabitur eget condimentum arcu. Aenean quis sapien risus, nec vehicula neque. Cras viverra dui non mi imperdiet at commodo orci hendrerit."; 
    ebook.ibookstorelink =@"http://itunes.apple.com/au/book/id445995313?mt=11"; 
    ebook.eBookCorpLink =@""; 
    ebook.AmazonLink =@""; 

    //Entry  
    [ebooks_list addObject:ebook];

    ebook = [[ebooks alloc] init]; 
    ebook.isbn =@"0000000000000"; 
    ebook.title =@"Book Title"; 
    ebook.author =@"Author"; 
    ebook.disc =@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam at sagittis mi. Donec consequat, nulla a rutrum posuere, ante ligula egestas erat, non bibendum magna risus non mauris. Sed scelerisque ligula metus, vel sodales nulla. Fusce elementum dolor in mi aliquam laoreet. Morbi a justo ullamcorper nisi eleifend pulvinar ac vitae tortor. Cras sit amet eros urna. Pellentesque eget turpis vitae ante facilisis consectetur. Curabitur eget condimentum arcu. Aenean quis sapien risus, nec vehicula neque. Cras viverra dui non mi imperdiet at commodo orci hendrerit."; 
    ebook.ibookstorelink =@"http://itunes.apple.com/au/book/id445995313?mt=11"; 
    ebook.eBookCorpLink =@""; 
    ebook.AmazonLink =@""; 
    
    [ebooks_list addObject:ebook];
I know this may be an easy question but I am stumped.

Any help would me muchly appreciated
Kiwi77 is offline   Reply With Quote
Old 11-30-2011, 07:28 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Kiwi77 View Post
Hi everyone,

I've searched the internet and am still having problems implementing XML into my project. At the moment I can set up an array using NSMutableArray and that works find. However all the data is stored in the AppDelegate.m.

Heres how I add entries into the array.

Code:
    ebooks_list = [NSMutableArray arrayWithCapacity:20];
    
    //First entry
    
    //Set var first
    ebooks *ebook;
    
    //Entry    
    ebook = [[ebooks alloc] init]; 
    ebook.isbn =@"0000000000000"; 
    ebook.title =@"Book Title"; 
    ebook.author =@"Author"; 
    ebook.disc =@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam at sagittis mi. Donec consequat, nulla a rutrum posuere, ante ligula egestas erat, non bibendum magna risus non mauris. Sed scelerisque ligula metus, vel sodales nulla. Fusce elementum dolor in mi aliquam laoreet. Morbi a justo ullamcorper nisi eleifend pulvinar ac vitae tortor. Cras sit amet eros urna. Pellentesque eget turpis vitae ante facilisis consectetur. Curabitur eget condimentum arcu. Aenean quis sapien risus, nec vehicula neque. Cras viverra dui non mi imperdiet at commodo orci hendrerit."; 
    ebook.ibookstorelink =@"http://itunes.apple.com/au/book/id445995313?mt=11"; 
    ebook.eBookCorpLink =@""; 
    ebook.AmazonLink =@""; 

    //Entry  
    [ebooks_list addObject:ebook];

    ebook = [[ebooks alloc] init]; 
    ebook.isbn =@"0000000000000"; 
    ebook.title =@"Book Title"; 
    ebook.author =@"Author"; 
    ebook.disc =@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam at sagittis mi. Donec consequat, nulla a rutrum posuere, ante ligula egestas erat, non bibendum magna risus non mauris. Sed scelerisque ligula metus, vel sodales nulla. Fusce elementum dolor in mi aliquam laoreet. Morbi a justo ullamcorper nisi eleifend pulvinar ac vitae tortor. Cras sit amet eros urna. Pellentesque eget turpis vitae ante facilisis consectetur. Curabitur eget condimentum arcu. Aenean quis sapien risus, nec vehicula neque. Cras viverra dui non mi imperdiet at commodo orci hendrerit."; 
    ebook.ibookstorelink =@"http://itunes.apple.com/au/book/id445995313?mt=11"; 
    ebook.eBookCorpLink =@""; 
    ebook.AmazonLink =@""; 
    
    [ebooks_list addObject:ebook];
I know this may be an easy question but I am stumped.

Any help would me muchly appreciated
You're creating eBook objects, and adding them to a mutable array. However, you did not say anything about XML other than mentioning that you are "implementing XML into my project."

What, exactly, is your question, and how does it relate to XML?

By the way, unless you're using ARC, you are leaking the ebook objects you create. You need to release each ebook object after you add it to the array.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 11-30-2011, 08:23 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2011
Location: Sydney, Australia
Posts: 13
Kiwi77 is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
You're creating eBook objects, and adding them to a mutable array. However, you did not say anything about XML other than mentioning that you are "implementing XML into my project."

What, exactly, is your question, and how does it relate to XML?

By the way, unless you're using ARC, you are leaking the ebook objects you create. You need to release each ebook object after you add it to the array.
Thank you for your message.

What i want to do is have a XML file in the iPhone's documents file that can be updated via a download from our site.

I guess the crutch of my question is how do i read an xml file and get it to populate into the array.

Thank you for the tip about leaking - i will look into that.

Cheers,
Marc

Last edited by Kiwi77; 11-30-2011 at 08:25 PM.
Kiwi77 is offline   Reply With Quote
Old 11-30-2011, 10:41 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Tasmania, Australia
Posts: 195
Son of a Beach is on a distinguished road
Default

Have a look at the documentation for NSXMLParser. I use it to parse KML files into an app.
Son of a Beach is offline   Reply With Quote
Reply

Bookmarks

Tags
nsmutablearray, 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: 397
16 members and 381 guests
AppsBlogger, chiataytuday, Clouds, David-T, dedeys78, Duncan C, e2applets, EvilElf, heshiming, iekei, leostc, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,912
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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