Amazon.com Widgets Chapter 15.10 for IOS.. need help.. driving me crazy..
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 19, 2013, 09:19:55 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 15 - Numbers, Strings, and Collections
| | | |-+  Chapter 15.10 for IOS.. need help.. driving me crazy..
Pages: [1]   Go Down
Print
Author Topic: Chapter 15.10 for IOS.. need help.. driving me crazy..  (Read 387 times)
TommyT
Newbie
*
Posts: 1






« on: October 12, 2011, 07:26:50 PM »

HI all, new to Xcode and Objective c..but have C programming exp. I've been working through the book and within chapter 15 I decided to try and make a small IOS app out of it. I have typed in the two classes for address card and address book exactly as they are in the book. what I'm trying to do is take the input from a button and create new entries based on a couple text fields. everything is connected in interface builder. I have it working using the following code when you push the button:

AddressCard *card1 = [[AddressCard alloc] init];

AddressBook *myBook = [[Addressbook Alloc] initWithName: @"Toms Address book"];

[card1 setname: aName andEmail: aEmail];

[myBook addCard: card1];

[myBook list]

[card1 release];
[myBook release];


What seems to happen is it will only save one card to the book at a time, the list function displays the card I just entered but when I enter a new one its gone only the new card is there now.. What am I doing wrong here? is there a different place I should put the:

AddressBook *myBook = [[Addressbook Alloc] initWithName: @"Toms Address book"];

I was thinking in the app delegate??

Any help would be greatly appreciated..

Thanks..
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #1 on: October 12, 2011, 08:55:55 PM »

Yes, you don't want to create a new address book each time a new address card is to be added to the address book.  You can add it to the application:didFinishLaunchingWithOptions method or in your view controller class (e.g., viewDidLoad).

Cheers,

Steve
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.