• 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: new class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new class


  • Subject: Re: new class
  • From: PGM <email@hidden>
  • Date: Thu, 20 Sep 2007 21:09:11 -0400

In a new class (subclass of NSObject) I have the following method:

- (DCPoint)convert { // gives this error: can not use an object as parameter to a method
DCPoint * DC = [[DCPoint alloc] init];


	// insert calculations here

	[DC initWithDistance:0 Course:0];
	return DC;						 // gives this error: incompatible types in return

}

Also note that you init DC twice, but alloc it only once. In general, init should always be used concertedly with alloc. The line before the return should most likely be divided into two lines where you use setters to change the variables of DC:


[DC setDistance:0];
[DC setCourse:0];

Cheers, Patrick
_______________________________________________

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


  • Follow-Ups:
    • Re: new class
      • From: "Shawn Erickson" <email@hidden>
References: 
 >new class (From: H M <email@hidden>)

  • Prev by Date: Core Data guidance Was: Calling processPendingChanges from awakeFromInsert
  • Next by Date: Re: new class
  • Previous by thread: Re: new class
  • Next by thread: Re: new class
  • Index(es):
    • Date
    • Thread