Using C Structs which contains ObjC Objects?
        Posted  
        
            by GuidoMB
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by GuidoMB
        
        
        
        Published on 2010-03-21T21:53:18Z
        Indexed on 
            2010/03/21
            22:01 UTC
        
        
        Read the original article
        Hit count: 461
        
objective-c
|best-practices
I'm using C structs in objc and I've created a function that assembles the structure like the one from the Cocoa API. The things is that this structure is not like NSRect o NSPoint this structure packs objc objects soo I'm seeing a potential memory leak here. Do I need to provide a function to 'release' the structure?
I'am not creating a ISKNewsCategory class because there will be no behavior but Do you think this is a good approach or I should define the class even doe there will be no behavior?
typedef struct ISK_NewsCategory {
    NSString *name;
    NSString *code
} ISKNewsCategory;
NS_INLINE ISKNewsCategory ISKMakeNewsCategory(NSString *name, NSString *code) {
    ISKNewsCategory category;
    category.name = [name retain];
    category.code = [code retain];
    return category;
}
        © Stack Overflow or respective owner