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 > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-23-2010, 12:37 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 16
korki696 is on a distinguished road
Default Going through an array adding an item every 2

Hey all,
I am working on a program and im sure what I need to do is fairly simple but I just cant figure it out. What I need to do is take an array i have that is full of numbers and then every 2 numbers I have to add a 0. For example:

Original:
5555555555555555

What I need:
550550550550550550550550

How could I do this?

Thanks
-Korki
korki696 is offline   Reply With Quote
Old 10-23-2010, 09:30 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 33
Wailord is on a distinguished road
Default

Quote:
Originally Posted by korki696 View Post
Hey all,
I am working on a program and im sure what I need to do is fairly simple but I just cant figure it out. What I need to do is take an array i have that is full of numbers and then every 2 numbers I have to add a 0. For example:

Original:
5555555555555555

What I need:
550550550550550550550550

How could I do this?

Thanks
-Korki
Code:
for(int x=2;x<[arrayName count];x+=3) {
   [arrayName insertObject:[NSNumber numberWithInt:0] atIndex:x];
}
Granted, I've been developing for a few months and could be well off. Worth a try, I guess? Let me know how it goes.

edit: this is assuming you're using an NSMutableArray, didn't occur to me you could be using something else
__________________
Check out Flowers for iPhone, or, possibly, Flowers for iPad, if you feel like making someone's day. Maybe check out our promo? Thanks!

Last edited by Wailord; 10-23-2010 at 09:32 PM.
Wailord 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: 460
17 members and 443 guests
alexeir, David-T, Dj_kades, foslock, iAppDeveloper, ilmman, j.b.rajesh@gmail.com, jeroenkeij, mer10, mkjarred, myach, pipposanta, QuantumDoja, robsmy, sacha1996, SLIC, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,928
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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