NSData * data;
NSFileHandle * file;
file = [NSFileHandle fileHandleForReadingAtPath: @"script.txt"]; //this is wrong, as I have to provide a full pathname, but disregard for now
[file seekToFileOffset: i]; //i not mentioned here, as this is only a snippet of code. Suffice to know that in the file it falls at the beginning of an integer I want to read
data = [file readDataOfLength: 5]; //5-digit integer that I want to read
現在我該如何將數據轉換爲可以使用的int數據(即執行算術運算)?Objective-C:將NSData轉換爲int或char
script.txt是否包含整數的純文本(即ASCII)表示形式,正如人們可能從其名稱和文件擴展名中假設的那樣? –
確實如此。 – Alexander