Re: Custom class method problem
Subject : Re: Custom class method problem
From: Shawn Erickson <email@hidden >
Date: Fri, 02 Sep 2005 15:04:23 -0700
Delivered-to: email@hidden
Delivered-to: email@hidden
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.
test.h:
@interface myObject : NSObject {
NSMutableDictionary *attributeList;
}
- (void)setAttributeName:(NSString *)attrValue forKey:(NSString *)
attrKey;
@end
test.m:
@implementation myObject
-(void)init {
attributeList = [[NSMutableDictionary alloc] init];
}
- (void)dealloc {
[attributeList release];
[super dealloc];
}
-(void)setAttributeName:(NSString *)attrValue forKey:(NSString *)
attrKey {
[attributeList setValue:attrValue forKey:attrKey];
}
@end
main.m:
char *tak1 = "TestAttr key 1";
char *tak2 = "TestAttr key 2";
char *tav1 = "Attr 1 value";
char *tav2 = "Attr 2 value";
myObj = [myObject new];
In general "new" is considered a legacy method, instead use
[[myObject alloc] init].
[myObj setAttributeName:[NSString stringWithCString: tav1] forKey:
[NSString stringWithCString: tak1]];
or more simply...
[myObj setAttributeName:@"Attr 1 value" forkey:@"TestAttr key 1"];
[myObj setAttributeName:[NSString stringWithCString: tav2] forKey:
[NSString stringWithCString: tak2]];
or more simply...
[myObj setAttributeName:@"Attr 2 value" forkey:@"TestAttr key 2"];
[myObj release]; //when done with myObj
---
Now try it.
-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
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.