Mailing Lists: Apple Mailing Lists

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

Custom class method problem



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

I can't seem to get the code below, using NSMutableDictionary, to perform as expected.  When the code is executed, myObj has no key/value pairs.  As I have no problem creating key/value pairs directly against an NSMutableDictionary object, so it's my implementation but I'm not seeing the problem.  Also, tips on better ways to expose class methods of objects are appreciated (i.e. here all I'm really trying to do is expose NSMutableDictionary's setValue:forKey:)...

Here's are the code snippets pertaining to the problem:

test.h:
@interface myObject : NSObject {
    NSMutableDictionary *attributeList;
}

- (void)setAttributeName:(NSString *)attrValue forKey:(NSString *)attrKey; 

@end

test.m:
@implementation myObject

-(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];
[myObj setAttributeName:[NSString stringWithCString: tav1] forKey:[NSString stringWithCString: tak1]];
[myObj setAttributeName:[NSString stringWithCString: tav2] forKey:[NSString stringWithCString: tak2]];

Thanks,
Phil 
 _______________________________________________
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.