• 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: cannot be sent to an abstract object of class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cannot be sent to an abstract object of class


  • Subject: Re: cannot be sent to an abstract object of class
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Sat, 4 Dec 2010 17:56:48 -0600

On Sat, Dec 4, 2010 at 5:17 PM, Shane
<email@hidden> wrote:
> @interface
> {
>        NSNumber *rate;
>        // ...
> }
> // ...
> #end
>
> - (id) init
> {
>        // …
>        rate = [[NSNumber alloc] initWithFloat:0.0];
>        // now has retain count of 1
> }
>
> - (void) myMethod
> {
>        // ...
>        [rate initWithFloat:[[config rate] floatValue]];
>        // …
> }
>
> *** initialization method -initWithFloat: cannot be sent to an
> abstract object of class NSCFNumber: Create a concrete instance!

alloc and init* must come as a pair, and only once. You can't call any
init* method on an object a second/third/etc time.

More to the point, NSNumber is an immutable class. If you want to
change the value, you have to alloc/init another one. There are a
bunch of immutable Foundation classes: NSArray, NSDictionary,
NSString, etc.
_______________________________________________

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: cannot be sent to an abstract object of class
      • From: Sherm Pendley <email@hidden>
References: 
 >cannot be sent to an abstract object of class (From: Shane <email@hidden>)

  • Prev by Date: Re: cannot be sent to an abstract object of class
  • Next by Date: Re: cannot be sent to an abstract object of class
  • Previous by thread: Re: cannot be sent to an abstract object of class
  • Next by thread: Re: cannot be sent to an abstract object of class
  • Index(es):
    • Date
    • Thread