开发者

Split strings error whats wrong with it

开发者 https://www.devze.com 2023-01-11 05:05 出处:网络
//Seperate into arrays NSString *NumberItems = [RawMessage componentsSeparatedByString:@\"|\"]; //Create the strings
    //Seperate into arrays
NSString *NumberItems = [RawMessage componentsSeparatedByString:@"|"];
//Create the strings
NSString *number1 = [NumberItems objectAtIndex:0];    
NSString *number2 = [NumberItems objectAtIndex:1];
NSString *number3 = [NumberItems objectAtIndex:2];    
NSString *number4 = [NumberItems objectAtIndex:3];
NSString *number5 = [NumberItems objectAtIndex:4];    
NSString *number6 = [NumberItems objectAtIndex:5];
NSString *number7 = [NumberItems objectAtIndex:6];    
NSString *number8 = [NumberItems objectAtIndex:7];
NSString *number9 = [NumberItems objectAtIndex:8];    
NSString *number10 = [NumberItems objectAtIndex:9];
开发者_如何学CNSString *message = [NumberItems objectAtIndex:10]; 

the string RawMessage contains this,

011597464952|01521545545|454545474|454545444|01521545545|454545474|454545444|01521545545|454545474|454545444|Hello world i am the message

the app just seems to jam after that ? and do i need to release NumberItems at the end and/or RawMessage


componentsSeparatedByString returns an NSArray - you need to do something like this:

NSArray *NumberItems = [RawMessage componentsSeparatedByString:@"|"];

That should fix it.


The first line should be:

NSArray *NumberItems = [RawMessage componentsSeparatedByString:@"|"];
0

精彩评论

暂无评论...
验证码 换一张
取 消