• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: id type in NSCoder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: id type in NSCoder


  • Subject: Re: id type in NSCoder
  • From: Ian McGregor <email@hidden>
  • Date: Thu, 18 Dec 2003 10:36:45 -0800

I am still getting weird values and crashes. :(

I have:

My Node
-----------
NSMutableDictionary *nodeData;

node data contains (amongst other objects) and NSMutableArray of
MyFields

My Fields
------------
NSString *fieldName;
id fieldValue;


as mentioned previously, the coding protocols for MyFields is encoding
and decoding the fieldValues correctly - proved with NSLog.

BUT, in the MyNode class, I cannot do anything with [[[nodeData
objectForKey:@"MyFields"] objectAtIndex:0] fieldValue] without getting
signal 10 (SIGBUS) issues.


For example, in MyNode:

- (id)initWithCoder:(NSCoder *)coder
{
     [super init];
     [self setNodeParent:[coder decodeObject]];
     [self setChildren:[coder decodeObject]];
     [self setNodeData:[coder decodeObject]];
     if ([nodeData objectForKey:@"MyFields"] == NULL) {
         NSLog(@"node data MyFields is null");
     } else {
         if ([[nodeData objectForKey:@"MyFields"] count] > 0) {
             NSLog(@"%@",[[[nodeData objectForKey:@"MyFields"]
objectAtIndex:0] fieldName]);   // this works and shows the field name
             if ([[[nodeData objectForKey:@"assetFields"]
objectAtIndex:0] fieldValue] == NULL) {
                 NSLog(@"fieldValue is null");
             } else {
                id value = [[[nodeData objectForKey:@"assetFields"]
objectAtIndex:0] fieldValue];
                 NSString *theClass = [value className];  // this
crashes with signal 10
                NSLog(@"value = %@",value); // this also crashes with
signal 10
             }
         }
     }
     [self setNodeLeaf:[coder decodeObject]];
     return self;
}

Any pointers appreciated.

Cheers,

Ian

On 17-Dec-03, at 11:37 PM, Ian McGregor wrote:

> Hi Scott,
>
> I have been bashing at this for a few hours now... and, as usual I
> think you are right. This SHOULD be working. I just proved it to myself
> by placing some NSLog's in there:
>
> NSLog(@"decode: fieldValue class is %@",[fieldValue class]);
>
> and
>
> NSLog(@"encode: fieldValue class is %@",[fieldValue class]);
>
> and they are both displaying the correct classes, with the exception of
> a few  (null)'s... I wonder if these (nulls) might might be the issue!
>
>
>
> For example, I set fieldValue as an NSNumber and got
> On 17-Dec-03, at 11:07 PM, Scott Anguish wrote:
>
>> how do you mean it isn't working?
>>
>> id just tells the compiler that you're not sure what you'll be
>> using... when the object is encoded, it should just handle it.
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: id type in NSCoder
      • From: Ian McGregor <email@hidden>
  • Prev by Date: Out of date precompiled symbol files
  • Next by Date: Re: id type in NSCoder
  • Previous by thread: Re: Out of date precompiled symbol files
  • Next by thread: Re: id type in NSCoder
  • Index(es):
    • Date
    • Thread