Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional iPhone and iPad Database Application Programming
This is the forum to discuss the Wrox book Professional iPhone and iPad Database Application Programming by Patrick Alessi; ISBN: 978-0-470-63617-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone and iPad Database Application Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 24th, 2011, 11:57 AM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Xcode 4 and chapter 4 iPad code

I am trying to get the chapter 4 code working while using Xcode 4.

I am running into a problem basically at page 103. I have the code entered but surveys are not getting added to the list when I hit the "add" button.

I am still trying to work through the issue, but was wondering if anyone else has run into this and possibly solved it.

Thanks!
  #2 (permalink)  
Old February 24th, 2011, 12:57 PM
Registered User
 
Join Date: Feb 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Fixed

I figured it out. I had skipped one line of code in the text, so nothing was getting updated.
  #3 (permalink)  
Old August 15th, 2011, 12:48 PM
Registered User
 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm working on the code from Chapter 4, the Survey. I have compiled the code and installed it on my iPad. When I enter survey data, and sync my iPad in iTunes, it does not show up as an XML file. Does anyone have a solution to this problem? Perlguy, did you have any luck with this?
  #4 (permalink)  
Old August 16th, 2011, 09:09 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

You need to change one of the method signatures in order for the data to persist. Since the introduction of iOS 4, and multitasking, the method

-(void)applicationWillTerminate:(UIApplication *)application

is rarely called since the application does not actually quit, but enters the background. In the AppDelegate method change this method signature to

-(void)applicationWillResignActive:(UIApplication *)application

The full listing would be

Code:
-(void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"Resigning active");

//- (void)applicationWillTerminate:(UIApplication *)application { ////This method is not being called and can be deleted
    // Serialize the rootViewController's surveyDataArray
    NSData *serializedData;
    NSString *error;
    
    serializedData = [NSPropertyListSerialization 
                      dataFromPropertyList:rootViewController.surveyDataArray
                      format:NSPropertyListXMLFormat_v1_0
                      errorDescription:&error];
    
    if (serializedData)
    {
        // Serialization was successful, write the data to the file system
        // Get an array of paths. 
        // (This function is carried over from the desktop)
        NSArray *documentDirectoryPath = 
            NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                                NSUserDomainMask, YES);
        NSString *docDir = [NSString stringWithFormat:@"%@/serialized.xml",
                            [documentDirectoryPath objectAtIndex:0]];
        
        [serializedData writeToFile:docDir atomically:YES];
    }
    else
    {
        // An error has occurred, log it
        NSLog(@"Error: %@",error);
    }
}

Assuming everything else is correct, the data should now be stored, and can be synced in iTunes
Bob


Similar Threads
Thread Thread Starter Forum Replies Last Post
Books on iPad johnzonie Forum and Wrox.com Feedback 9 October 28th, 2013 12:28 AM
Want iPad get iPhone traffic4biz BOOK: Beginning iPad Application Development 1 August 21st, 2010 03:42 PM
Why an iPad ebook that you cannot see on a iPad? csburris BOOK: Beginning iPad Application Development 2 July 7th, 2010 10:11 AM
Iphone to Ipad Development tips ipadboy1 BOOK: Beginning iPad Application Development 0 May 1st, 2010 11:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.