Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

xcode - objective-c loading data from excel

I'm writing an application for the iPad that will tell us whether or not someone is on court at a tennis tournament. Basically, just an application with a list of names each with an on/off button next to them. Once the on button is pressed, their name turns red, thus they are on court.

Is there any way, to make this easier for myself, I would be able to connect it to my computer and load in a list of names once the application is complete? That would save me from having to individually enter/modify names manually.

Thanks in advance, Louis.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Though your question is pretty... vague, one suggestion :

importing Spreadsheet-like data could easily be done by import the .csv version (Comma-separated value) of a Spreadsheet.

A comma-separated values (CSV) file stores tabular data (numbers and text) in plain-text form. Plain text means that the file is a sequence of characters, with no data that has to be interpreted instead, as binary numbers. A CSV file consists of any number of records, separated by line breaks of some kind; each record consists of fields, separated by some other character or string, most commonly a literal TAB or comma. Usually, all records have an identical sequence of fields.

Example :

Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38

Then, you could simply :

(1) Load your csv file as a simple text file

NSString* contents = [NSString stringWithContentsOfFile:filename
                                               encoding:NSUTF8StringEncoding 
                                                  error:nil];

(2) Get the lines

NSArray* lines = [contents componentsSeparatedByString:@"
"];

(3) Parse each line's fields

for (NSString* line in lines)
{
    NSArray* fields = [line componentsSeparatedByString:@","];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...