objective c - Properly defining a static NSString* c-style array under ARC -
objective c - Properly defining a static NSString* c-style array under ARC -
in implementation file, have static 2-dimensional c-style array of nsstring* defined as:
static nsstring* thecolorarray[][3] = { [redtype] = {@"red", @"blah", @"yes"}, [bluetype] = {@"blue", @"yadda", @"yes"}, ..... }
the method in question accesses array like:
-(nsstring*)value:(nsinteger)value { homecoming thecolorarray[value][0]; }
this seems work fine 99% of time...but when fails work fails exc_bad_access - kern_invalid_address @ 0x11
i've verified value
parameter not beyond bounds of array. seems odd address 0x11
...which kind of implies array has not been initialized.
so happening here? there "gotcha" need aware of arc , c-style arrays?
the documentation clear structs cannot contain arc'd objects, argue applies multidimensional array datums well, though doesn't so. did seek this:
static nsstring __unsafe_unretained * thecolorarray[][3] = ...
this take objects allocated here out of arc , remove possibility compiler aggressively nulling shouldn't be.
assuming that's problem. maybe if you're able step debugger, can see symbol beingness dereferenced when errs?
objective-c automatic-ref-counting
Comments
Post a Comment