问题描述
我正在为iPad编写一个应用程序,告诉我们是否有人在网球赛场上。基本上,只是一个应用程序的名称列表,每个旁边都有一个开/关按钮。一旦按下按钮,他们的名字变成红色,因此他们在法庭上。
有任何方式,使这更容易为自己,我会能够连接到我的计算机,并加载在名称的列表,一旦应用程序完成?这将使我不必手动单独输入/修改名称。
提前感谢,
Louis。
虽然你的问题很漂亮...一个建议:
导入类似电子表格的数据很容易通过导入电子表格的 .csv
版本(逗号分隔值)来完成。
示例: >
Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
(1)以简单的文本文件加载csv文件
NSString * contents = [NSString stringWithContentsOfFile:filename
encoding:NSUTF8StringEncoding
error:nil];
(2)取得线条
NSArray * lines = [content componentsSeparatedByString:@\\\
];
(3)解析每行的字段
for(NSString * line in lines)
{
NSArray * fields = [line componentsSeparatedByString:@,];
}
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.
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.
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:@"\n"];
(3) Parse each line's fields
for (NSString* line in lines)
{
NSArray* fields = [line componentsSeparatedByString:@","];
}
这篇关于目标c加载数据从excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!