Second line throws an EXC_BAD_ACCESS exception. I'm not too familiar with Objective C or C, but an SDK I'm using takes C parameters. What am I doing wrong here?
unsigned char *header = (unsigned char*)[
[ticket_design objectForKey:@"header"]
cStringUsingEncoding:NSStringEncodingConversionAllowLossy
];
int header_length = strlen((const char*)header);
If possible, I would just go the standard route by making header
an NSString
and then:
int len = [myString length];
I think this would prevent the ugly crash... but it seems like header
is empty or not null terminated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.