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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-01-2011, 06:38 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 2
joseph.gruber is on a distinguished road
Default NSArray String -> Substring

Hi all! I'm pretty new to Objective-C and XCode coming from a .Net background. I'm hoping you might be able to help me. Am I not able to do this:

Code:
self.catalogNumber = [tleSetStrings objectAtIndex: 1 substringWithRange:NSMakeRange(2,5)];
Basically what I'd like to do is pull the string at index 1 in the tleSetStrings array and then return characters 2 through 7 (5 char count) from that string. I was hoping to combine it into one easy line of code instead of having to pull the string from the array, store it in a temp variable and then return the substring.

Any advice is appreciated! Thanks.

Joseph
joseph.gruber is offline   Reply With Quote
Old 06-01-2011, 07:38 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 2
joseph.gruber is on a distinguished road
Default

I ended up getting the result by writing:

Code:
self.catalogNumber = [[NSString stringWithFormat:@"%@", [tleSetStrings objectAtIndex: 1]] substringWithRange:NSMakeRange(2,5)];
This works for me but if I'm doing this wrong or there's a better way I'm all ears. Thanks!
joseph.gruber is offline   Reply With Quote
Reply

Bookmarks

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: 486
16 members and 470 guests
7twenty7, AlanFloyd, AppsBlogger, David-T, HemiMG, iAppDeveloper, imac74, Jaxen66, lovoyl, Music Man, mutantskin, Paul Slocum, SLIC, solardrift, unicornleo, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,683
Threads: 94,131
Posts: 402,932
Top Poster: BrianSlick (7,990)
Welcome to our newest member, unicornleo
Powered by vBadvanced CMPS v3.1.0

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