Friday, 15 April 2011

c++ - EXC_BAD_ACCESS uint32_t -



c++ - EXC_BAD_ACCESS uint32_t -

i attempting implement extension method on nsdata in obj c. extension method calls cpp lib method.

here method signature of cpp method:

void process(char *result) { }

here extension method calling cpp method:

- (nsdata *)process { uint32_t result; process((char*)&result); // @ point result shows 2949384954 value nsdata *d = [nsdata datawithbytes:&result length:sizeof(result)]; homecoming d; }

when utilize process , assign returned (nsdata*), exc_bad_access error. i'm sure has improper utilize of pointers or references, can't figure out. in advance.

the code next code works fine:

uint32_t result = 2949384954; nsdata *d = [nsdata datawithbytes:&result length:sizeof(result)]; nslog(@"d: %@", d);

nslog output:

d: <fa0accaf>

there issue way method called.

back "extension method ". mean that? create function add together method class.

c++ objective-c objective-c++

No comments:

Post a Comment