开发者

How to make the fowling data conversion: NSArray to char

Well I'm currently calling a method that requires one char input method, but I the data for it is loaded from a file than putted into an array and then I want to convert one of the array's elements to an const char (all the array's elements are URL's). What basically I'm trying to do is to make the program to load a specific file and then put the lines separately into the array's elements (I mean: 1 line = 1 new array element), and then I made a for loop like this:

NSUInteger nElements = [array count];
int i;
for (i = 0; i<nElements; i++) {
    const char* urlNa开发者_开发百科me = [[array objectAtIndex:i] cStringUsingEncoding:NSUTF8StringEncoding]; // I don't know if this is correct but don't works :)
}


If it's an array of NSURL objects you'd have to convert them to strings like this:

const char* urlName = [[[array objectAtIndex:i] absoluteString] UTF8String];


Assuming it's an array of NSString, you could do this:

const char* urlName = [[array objectAtIndex:i] UTF8String];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜