English 中文(简体)
模拟式安全分机从 com号分离至NSArray[复制]
原标题:Convert NSString separated by comma to NSArray [duplicate]
This question already has answers here:
Closed 10 years ago.

Possible Duplicate:
Convert NSArray to NSString in Objective-C

我有一阵列,内容是:

 (
            "<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246",
            "<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324",
            "<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367"
 )

我将以下守则用于指定一个安保部,以制定我的标准:

NSString *myString = [myArray description];

而现在仍然如预期的那样:

 (
            "<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246",
            "<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324",
            "<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367"
 )

现在,我要说,我要把我的雕刻改成一个叫做新阵列的阵列。

NSArray *newArray = [[NSArray alloc]init];
newArray = [myString componentsSeparatedByString:@","];

但新阿雷拉的内容现在有所不同:

(       
"(
    "<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246"",
        "
    "<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324"",
        "
    "<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367""
)"
) 

Any idea what I need to do to fix this?

最佳回答

两种方法

用途

NSString *myString = [myArray componentsJoinedByString:@","]; //instead of [myArray description];
问题回答

这是国家航空航天局的印刷材料。

"(
"<MPConcreteMediaItem: 0x1b7dd0> 8671085923283003246"",
    "
"<MPConcreteMediaItem: 0x1b7e50> 16275751483823231324"",
    "
"<MPConcreteMediaItem: 0x1b7e70> 4976771456698615367""
)"

To print out the individual elements in the array try this and see what happens

NSString *myString1 = [myArray objectAtIndex:1];
NSString *myString2 = [myArray objectAtIndex:2];
NSLog(myString1);
NSLog(myString2);

也许我没有一件事,但你在“C”型护卫而不是“NSString”上采取行动。 你们需要更多的“@”。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签