1

我目前正在开发一个上传 EKEvent 的 iOS 应用程序,event.description它是一个基本的 NSString。

问题是,当我在上传文件后从服务器下载文件时,解析字符串很麻烦。

目前,这是我下载文本文件时正在查看的字符串

"EKEvent <0x9dd50b0> {EKEvent <0x9dd50b0> {title = Another Event SC; location = A House; calendar = EKCalendar <0x994e7f0> {title = Calendar; type = Local; allowsModify = YES; color = #0E61B9;}; alarms = (null); URL = (null); lastModified = 2013-04-11 20:44:58 +0000; timeZone = (null)}; location = A House; startDate = 2012-10-11 07:00:00 +0000; endDate = 2012-10-13 06:59:59 +0000; allDay = 1; floating = 1; recurrence = (null); attendees = (null)}"

我认为解析这个文件不会很糟糕,但我对目标 C 相当陌生。

这是我到目前为止所做的

NSString *anotherString = [NSString stringWithFormat:components[i]];
NSLog(@"%@", anotherString);

//EKEventStore *eventStore = [[EKEventStore alloc] init];
//EKEvent *event  = [EKEvent eventWithEventStore:eventStore];

NSArray *totalEventInfo = [anotherString componentsSeparatedByString:@"= "];

NSLog(@"%@",totalEventInfo);

假设anotherString包含之前显示的下载文本文件字符串。这是分离字符串并将每个分离的字符串存储到 totalEventInfo 的增量组件后的输出。

"EKEvent <0x9dbe430> {EKEvent <0x9dbe430> {title ",
"Another Event SC; location ",
"A House; calendar ",
"EKCalendar <0x99e9570> {title ",
"Calendar; type ",
"Local; allowsModify ",
"YES; color ",
"#0E61B9;}; alarms ",
"(null); URL ",
"(null); lastModified ",
"2013-04-11 20:44:58 +0000; timeZone ",
"(null)}; location ",
"A House; startDate ",
"2012-10-11 07:00:00 +0000; endDate ",
"2012-10-13 06:59:59 +0000; allDay ",
"1; floating ",
"1; recurrence ",
"(null); attendees ",
"(null)}"

)

如何指定字符串的域?前任。从一个字符串中读入,从一个字符'='开始的一串字符并在下一个';'处结束。

也许这不是解析信息的好方法。

我在考虑不是上传包含 EKEvent 的 event.description 的文件,而是上传一个带有 event.title、event.startdate、event.enddate 等的文件,而不是 event.description 并且每次都必须解析文件下载。

建议或意见表示赞赏:)

4

0 回答 0