FROM : Apirak
DATE : Sat Dec 11 06:40:02 2004
my -setWord and -getWord work very well, but it will show me an error
after I get it from NSMutableArray.
>> Word *wd = [[myArray objectAtIndex:0] retain];
>> NSLog(@"word equal %@", [wa getWord]);
I think it because "retains or copies" problems that you said. // my
basic skill is java don't know much about vector :p
this is my -setWord and -getWord
NSString *word;
- (NSString *) getWord {
return word;
}
- (void) setWord:(NSString *)newword {
word = newword;
}
Thank you :)
Apirak Panatkool
e-mail: <email_removed>
phone: 01-4033320
On Dec 11, 2004, at 11:35 AM, Brendan Younger wrote:
>
> On Dec 10, 2004, at 10:14 PM, Apirak wrote:
>
>> I store my object (Word) in NSMutableArray. How do I get it back like
>> this
>>
>> NSMutableArray *myArray = [[NSMutableArray alloc] init];
>>
>> Word *word = [[Word alloc] init];
>> [word setWord:@"test"];
>>
>> [myArray addObject:word];
>>
>> Word *wd = [[myArray objectAtIndex:0] retain];
>> NSLog(@"word equal %@", [wa getWord]);
>
> Which variable is "wa", you've assigned "wd" the value from the array.
> Also, the retain is probably unnecessary. You should check that
> -setWord: retains or copies its argument and that -getWord is
> returning the correct object.
>
>> don't have any error in compile time but in run time it show this
>> message
>>
>> XMLData has exited due to signal 10 (SIGBUS).
>
> When you get this error, you've dereferenced an invalid pointer
> somewhere.
>
>> I am very new to Obj-C and Cocoa, What happen with my code?
>
> Brendan Younger
>
DATE : Sat Dec 11 06:40:02 2004
my -setWord and -getWord work very well, but it will show me an error
after I get it from NSMutableArray.
>> Word *wd = [[myArray objectAtIndex:0] retain];
>> NSLog(@"word equal %@", [wa getWord]);
I think it because "retains or copies" problems that you said. // my
basic skill is java don't know much about vector :p
this is my -setWord and -getWord
NSString *word;
- (NSString *) getWord {
return word;
}
- (void) setWord:(NSString *)newword {
word = newword;
}
Thank you :)
Apirak Panatkool
e-mail: <email_removed>
phone: 01-4033320
On Dec 11, 2004, at 11:35 AM, Brendan Younger wrote:
>
> On Dec 10, 2004, at 10:14 PM, Apirak wrote:
>
>> I store my object (Word) in NSMutableArray. How do I get it back like
>> this
>>
>> NSMutableArray *myArray = [[NSMutableArray alloc] init];
>>
>> Word *word = [[Word alloc] init];
>> [word setWord:@"test"];
>>
>> [myArray addObject:word];
>>
>> Word *wd = [[myArray objectAtIndex:0] retain];
>> NSLog(@"word equal %@", [wa getWord]);
>
> Which variable is "wa", you've assigned "wd" the value from the array.
> Also, the retain is probably unnecessary. You should check that
> -setWord: retains or copies its argument and that -getWord is
> returning the correct object.
>
>> don't have any error in compile time but in run time it show this
>> message
>>
>> XMLData has exited due to signal 10 (SIGBUS).
>
> When you get this error, you've dereferenced an invalid pointer
> somewhere.
>
>> I am very new to Obj-C and Cocoa, What happen with my code?
>
> Brendan Younger
>
| Related mails | Author | Date |
|---|---|---|
| Apirak | Dec 11, 05:14 | |
| Apirak | Dec 11, 06:40 | |
| Larry Fransson | Dec 11, 08:08 | |
| mmalcolm crawford | Dec 11, 11:15 | |
| mmalcolm crawford | Dec 11, 11:23 |






Cocoa mail archive

