stringWithCString deprecated... so what do i use with char* returned by sysctlbyname?

Viewed 8302

I know how to handle this when changing stringWithCString in SQLite... you just stringWithUTF8String instead. Is this the same with a char * when it is returned by sysctlbyname? (see code below)

- (NSString *) platform{
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithCString:machine];
    free(machine);
    return platform;
}

Thanks in advance!

4 Answers
Related