FROM : Marcel Borsten
DATE : Mon Nov 05 20:43:30 2007
Thank for your reply. It looks like you were right about me not
managing the life of the objects correctly. I had another look at that
part of the code and changed the sequence, now it works perfectly,
Thanks!
> On 11/5/07, Marcel Borsten <<email_removed>> wrote:
>
>> I'm using the following code to fill a NSMutableArray with strings
>> from the NSDictionary object. The for loop gets the instances of the
>> keys 'name' and puts the string in the mutable array object
>> 'firstNames'. In my program it uses the firstNames-array to fill a
>> NSPopupButton with the Array of NSStrings. When that happens the
>> program exits with a "EXC_BAD_ACCESS"-error.
>
> When what happens? What it the stack trace at the time of the crash?
>
>> It looks to me that the
>> objects in the returned mutable array are not NSString objects.
>> When I
>> debug, Xcode shows my NSString-value as 'invalid'.
>
> Consider using NSLog to help trace what is taking place however the
> debugger is usually the best way. Are you sure you are using a debug
> build of you application and stopping at a point in time that ensures
> the vars you are interested in are valid (in scope).
>
> For example try using the following code...
>
> ...
> NSArray *myArray = [dict objectForKey: @"List"];
> NSLog(@"myArray=%@", myArray);
>
> firstNames = [NSMutableArray array];
>
> int i, myNameList = [myArray count];
> for ( i = 0; i < myNameList; i++ ) {
> NSDictionary *nameEntry = [myArray objectAtIndex: i];
> NSLog(@"nameEntry=%@", nameEntry);
>
> NSString *name = [nameEntry valueForKey:@"name"];
> NSLog(@"name=%@", name);
>
> [firstNames addObject: name];
> }
> ...
>
> If the above logs what you expect then your problem is someplace
> else... As a guess I would say you aren't managing the life of
> firstNames correctly and it is disappearing before you get a chance to
> update your view object with the data.
>
> You don't list how you populate the NSPopupButton.
>
> -Shawn
>
DATE : Mon Nov 05 20:43:30 2007
Thank for your reply. It looks like you were right about me not
managing the life of the objects correctly. I had another look at that
part of the code and changed the sequence, now it works perfectly,
Thanks!
> On 11/5/07, Marcel Borsten <<email_removed>> wrote:
>
>> I'm using the following code to fill a NSMutableArray with strings
>> from the NSDictionary object. The for loop gets the instances of the
>> keys 'name' and puts the string in the mutable array object
>> 'firstNames'. In my program it uses the firstNames-array to fill a
>> NSPopupButton with the Array of NSStrings. When that happens the
>> program exits with a "EXC_BAD_ACCESS"-error.
>
> When what happens? What it the stack trace at the time of the crash?
>
>> It looks to me that the
>> objects in the returned mutable array are not NSString objects.
>> When I
>> debug, Xcode shows my NSString-value as 'invalid'.
>
> Consider using NSLog to help trace what is taking place however the
> debugger is usually the best way. Are you sure you are using a debug
> build of you application and stopping at a point in time that ensures
> the vars you are interested in are valid (in scope).
>
> For example try using the following code...
>
> ...
> NSArray *myArray = [dict objectForKey: @"List"];
> NSLog(@"myArray=%@", myArray);
>
> firstNames = [NSMutableArray array];
>
> int i, myNameList = [myArray count];
> for ( i = 0; i < myNameList; i++ ) {
> NSDictionary *nameEntry = [myArray objectAtIndex: i];
> NSLog(@"nameEntry=%@", nameEntry);
>
> NSString *name = [nameEntry valueForKey:@"name"];
> NSLog(@"name=%@", name);
>
> [firstNames addObject: name];
> }
> ...
>
> If the above logs what you expect then your problem is someplace
> else... As a guess I would say you aren't managing the life of
> firstNames correctly and it is disappearing before you get a chance to
> update your view object with the data.
>
> You don't list how you populate the NSPopupButton.
>
> -Shawn
>
| Related mails | Author | Date |
|---|---|---|
| Marcel Borsten | Nov 5, 18:59 | |
| Shawn Erickson | Nov 5, 19:37 | |
| Paul Goracke | Nov 5, 20:24 | |
| Marcel Borsten | Nov 5, 20:43 |






Cocoa mail archive

