Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom class method problem




On Sep 2, 2005, at 4:01 PM, Phil - Pub wrote:

Shawn,

Thanks for the reply.  Now a follow-up...

On Sep 2, 2005, at 6:04 PM, Shawn Erickson wrote:

On Sep 2, 2005, at 2:48 PM, Phil - Pub wrote:

I've run out of ideas on what I'm doing wrong here..



This isn't a Objective-C language question, in the future use the Cocoa-dev list found on the same site you found this list.

I debated sending to cocoa-dev but the answers provided seem to indicate that this was the right choice even though this problem involves Cocoa, the root issue seems to be my understanding of what Objective C needs/is doing. Please read on...

This list isn't really about programming question in Objective-C but the language itself, its theory, runtime implementation, etc.


It was my (mis?)understanding that initialization of class objects would happen automatically when I call [[myObject alloc] init]. Your information tells me I need to handle object allocation in the class myself which is fine if that's what needs to be done... just trying to understand what needs to happen.

Yes you allocate objects when you need them and assign pointers to point at them.


However, I copied and pasted this snippet and it caused some compiler warnings:
/Users/phil/Documents/Development/Mac OS X/Projects/Test - Cocoa App/test.m:19: warning: multiple methods named '-init' found
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h: 72: warning: using '-(id)init'
/Users/phil/Documents/Development/Mac OS X/Projects/Test - Cocoa App/test.m:18: warning: also found '-(void)init'


as well as runtime errors:
2005-09-02 18:13:33.241 Test - Cocoa App[2287] *** -[NSCFDictionary setAttributeName:forKey:]: selector not recognized [self = 0x306c10]
2005-09-02 18:13:33.241 Test - Cocoa App[2287] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSCFDictionary setAttributeName:forKey:]: selector not recognized [self = 0x306c10]

Well I wrote it in mail... so I am not surprise I mistyped something in the 1 minute I spent responding.


-(void)init should be...

-(id)init {
    attributeList = [[NSMutableDictionary alloc] init];
    return self;
}

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/objc-language/email@hidden

This email sent to email@hidden
References: 
 >Custom class method problem (From: Phil - Pub <email@hidden>)
 >Re: Custom class method problem (From: Shawn Erickson <email@hidden>)
 >Re: Custom class method problem (From: Phil - Pub <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.