• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: a newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a newbie question


  • Subject: Re: a newbie question
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 15 Nov 2008 18:51:26 -0600

So far, nobody that I've seen has pointed out the specific error in the code:

On Nov 10, 2008, at 9:00 PM, Michael wrote:

	Fraction *myFraction;
	myFraction= [Fraction alloc];
	myFraction= [Fraction init];  /*  ???  */

You are calling init on the class Fraction, not on the instance that you've allocated. The last line should have been written as:


	myFraction = [myFraction init];

although, as mentioned, it's customary to always initialize the allocated instance within the same expression where it was allocated, with this pattern:

	myFraction = [[Fraction alloc] init];

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >a newbie question (From: Michael <email@hidden>)

  • Prev by Date: Re: Finder's sidebar background color
  • Next by Date: Re: Detecting in/activity
  • Previous by thread: Re: a newbie question
  • Next by thread: System Preferences Pane: CGWindowContextCreate error
  • Index(es):
    • Date
    • Thread