How to split a string of words and add to an array - Objective C

Posted by user1412469 on Stack Overflow See other posts from Stack Overflow or by user1412469
Published on 2012-07-04T09:10:45Z Indexed on 2012/07/04 9:15 UTC
Read the original article Hit count: 362

Filed under:
|

Let's say I have this:

NSString *str = @"This is a sample string";

How will I split the string in a way that each word will be added into a NSMutableArray?

In VB.net you can do this:

Dim str As String
    Dim strArr() As String
    Dim count As Integer
    str = "vb.net split test"
    strArr = str.Split(" ")
    For count = 0 To strArr.Length - 1
        MsgBox(strArr(count))
    Next

So how to do this in Objective-C? Thanks

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about string