• 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: "Shawn Erickson" <email@hidden>
  • Date: Thu, 20 Sep 2007 18:59:32 -0700

On 9/20/07, PGM <email@hidden> wrote:
> > 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];

...and you are leaking the DCPoint instance that gets allocated (not
following the Cocoa memory "contract").

-Shawn
_______________________________________________

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: H M <email@hidden>
References: 
 >new class (From: H M <email@hidden>)
 >Re: new class (From: PGM <email@hidden>)

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