Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-25-2010, 07:00 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 60
Question split string when at semicolon

Hello.!

I have string from database of:

"image1.png;image2.png;image3.png"

i want to break it from semicolon. for ex(image1.png etc...)

- I want it in array instad of string.
-> Anyone help me to separate this images from string to Array..

Thank You in advance.
imsatasia is offline   Reply With Quote
Old 02-25-2010, 07:08 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 55
Default

NSString has this nifty method:

Code:
- (NSArray *)componentsSeparatedByString:(NSString *)separator
xyster is offline   Reply With Quote
Old 02-25-2010, 07:19 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 60
Default

Quote:
Originally Posted by xyster View Post
NSString has this nifty method:

Code:
- (NSArray *)componentsSeparatedByString:(NSString *)separator
I'm new to Objective-C.

Wil you please explain with example.

Thank You
imsatasia is offline   Reply With Quote
Old 02-25-2010, 07:24 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 55
Default

Assuming you have an NSString called myFantasticString with the contents as you described, then the code to get an array of the elements would be:
Code:
NSArray *myArray = [myFantasticString componentsSeparatedByString:@";"];

Last edited by xyster; 02-25-2010 at 07:30 PM.
xyster is offline   Reply With Quote
Old 02-25-2010, 07:50 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 60
Default

Quote:
Originally Posted by xyster View Post
Assuming you have an NSString called myFantasticString with the contents as you described, then the code to get an array of the elements would be:
Code:
NSArray *myArray = [myFantasticString componentsSeparatedByString:@";"];
Thank you Xyster.

Will you please tell me how to transfer this array to another view (to other xib).

here is my code:
Code:
NSString *images = [application Image];
	NSArray *imagesArray = [images componentsSeparatedByString:@";"];
I want to transfer imagesArray to other view.
imsatasia is offline   Reply With Quote
Reply

Bookmarks

Tags
string

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 240
16 members and 224 guests
@sandris, ADY, Alsahir, dacapo, Dani77, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, timle8n1, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:01 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0