所以我有一个非常大的字符串,我想在每一行上分开并将每一行作为对象放在一个数组中。在objective-c中,这可以使用:
NSArray *piecesArray = [tmpString componentsSeparatedByString:@"\n"];
但是如果我在monoTouch中尝试这个,我会将system.string []作为返回值。这是我在c#中使用的代码:
var defaults = NSUserDefaults.StandardUserDefaults;
//Collecting Trace and Trace data from link + security code and converting Track and Trace data into string
TracTraceDataString = NSString.FromData (NSData.FromUrl
(NSUrl.FromString ("http://plex.janssen1877.com/app/life/" + defaults ["SecurityToken"])),
NSStringEncoding.UTF8);
//Seperating the string and putting each object in the array
TrackTraceDataArray = TracTraceDataString.Split (new char[] { '\n' }, 2);
Console.WriteLine (TrackTraceDataArray);
答案 0 :(得分:3)
变化:
Console.WriteLine (TrackTraceDataArray);
为:
foreach (string s in TrackTraceDataArray)
Console.WriteLine (s);