Serialize struct with pointers to NSData

Posted by leolobato on Stack Overflow See other posts from Stack Overflow or by leolobato
Published on 2010-05-18T01:37:04Z Indexed on 2010/05/18 1:40 UTC
Read the original article Hit count: 650

Filed under:
|
|
|
|

Hey guys,

I need to add some kind of archiving functionality to a Objective-C Trie implementation (NDTrie on github), but I have very little experience with C and it's data structures.

struct trieNode
{
    NSUInteger key;
    NSUInteger count,
    size;
    id object;
    __strong struct trieNode ** children;
    __strong struct trieNode * parent;
};

@interface NDTrie (Private)
- (struct trieNode*)root;
@end

What I need is to create an NSData with the tree structure from that root - or serialize/deserialize the whole tree some other way (conforming to NSCoding?), but I have no clue how to work with NSData and a C struct containing pointers.

Performance on deserializing the resulting object would be crucial, as this is an iPhone project and I will need to load it in the background every time the app starts.

What would be the best way to achieve this?

Thanks!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa