I want to create an object called Note . Then I want to assign some values to it’s fields and display them in the console to verify that all of this works properly.
Note.h
#import <Foundation/Foundation.h>
@interface Note : NSObject
{
NSNumber *position;
NSString *syllable;
}
@property(nonatomic, retain)NSNumber *position;
@property(nonatomic, retain)NSString *syllable;
@end
Note.m
#import "Note.h"
@implementation Note
@dynamic position;
@dynamic syllable;
@end
After this , in another class I want to assign some values to the fields .
-(void) configNote:(Note*)not
{
not = [Note alloc];
[not setPosition:[NSNumber numberWithInt:2]];
[not setSyllable:@"Twin-"];
}
.....
Note *note;
[self configNote:note];
NSLog(@" pos : %d syl : %@ ",[[note position] integerValue],[note syllable]);
I tried to use @synthesize instead of @dynamic but still nothing changes . The reason of the error is : -[Note setPosition:]: unrecognized selector sent to instance 0x733d060
inityour note and use custom init method to initialize ivars and change dynamic to synthesizeand for better use this init to initialize your varibales