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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-11-2011, 01:39 AM   #1 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Question Choose 3 random strings from array that are different than another string?

Hey,

I want to choose 3 NSStrings from an NSArray. I also have a string named answerString. With these 3 NSStrings they cannot be the same as answerString (answerString is a NSString that is in this NSArray also).

Is it possible to create 3 NSStrings that are unique from answerString without having to do anything too complicated?

I just need some tips on how to go upon this!

Thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 12-11-2011, 10:14 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 280
dapis is on a distinguished road
Default

Quote:
Originally Posted by Objective Zero View Post
Hey,

I want to choose 3 NSStrings from an NSArray. I also have a string named answerString. With these 3 NSStrings they cannot be the same as answerString (answerString is a NSString that is in this NSArray also).

Is it possible to create 3 NSStrings that are unique from answerString without having to do anything too complicated?

I just need some tips on how to go upon this!

Thanks!
There's a simple solution to this common type of problem.

Generate a random ordering of the strings (say by shuffling an array that includes all the strings except for the answer string) and then choose the first
three strings in the result.
dapis is offline   Reply With Quote
Old 12-11-2011, 02:05 PM   #3 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Ive never heard of shuffling a array before. Do you have any links or anything to help me get this?
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 12-11-2011, 02:36 PM   #4 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

How about searching for "shuffle array" here: iPhone Dev SDK Forum - Search Forums
baja_yu is offline   Reply With Quote
Old 12-11-2011, 03:51 PM   #5 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Wow, that really helped and fixed my issue thanks!
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 12-11-2011, 03:52 PM   #6 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

You're welcome. And feel free to Search the forum more often. A lot of common tasks and problems were already asked and answered here, some many times.
baja_yu 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: 403
11 members and 392 guests
7twenty7, AppsBlogger, David-T, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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