2

所以我有一个非常大的字符串,我想在每一行上分开,并将每一行作为对象放在一个数组中。在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);
4

1 回答 1

3

改变:

Console.WriteLine (TrackTraceDataArray);

到:

foreach (string s in TrackTraceDataArray)
    Console.WriteLine (s);
于 2013-03-22T12:53:51.860 回答