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 12-30-2009, 02:40 PM   #1 (permalink)
Registered Member
 
AppStoreMod's Avatar
 
Join Date: Jul 2009
Location: Sacramento,CA
Posts: 90
Send a message via Skype™ to AppStoreMod
Default Shorten A Bit Of Text In A UITextView and Make It Pop Up In A UIAlertView

Okay say you have a UITextField and a UITextView. Now when you type into the UITextField and then you click Done on the keyboard so it goes away and then whatever you typed into the UITextField it will pop up in the UITextView. I got that all working. But lets say you typed "I will be right back" and then you click Convert on the top button corner. Then it will convert and it will pop up in a UIAlertView with your new message. So in the UIAlertView it should say it converted it to "I will brb" how can I make it convert just some bits of text in code? I don't want it to convert it to a whole new thing just a bit. So like from I will be right back to I will brb. How can I do that? I really need this asap. Also I am not referring to this code.

if(textView.text isEqualToString:@"I will Be right back") {
textView.text = @"BRB"
}

I am not referring to that code above. That will replace the whole text. I want it to just change a bit of text and still have the other text there.
__________________
- AppStoreMod
Youtube | Website | Twitter | Xcode Video Tutorials | AppStoreApps
AppStoreMod is offline   Reply With Quote
Old 12-31-2009, 06:13 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Have a look at:
Code:
[textView.text stringByReplacingOccurancesOfString:@"I will be right back" WithString:@"BRB];
It looks something like that anyway, I think it's what you're looking for.

Tom
harrytheshark is offline   Reply With Quote
Old 12-31-2009, 12:00 PM   #3 (permalink)
Registered Member
 
AppStoreMod's Avatar
 
Join Date: Jul 2009
Location: Sacramento,CA
Posts: 90
Send a message via Skype™ to AppStoreMod
Default

Quote:
Originally Posted by harrytheshark View Post
Have a look at:
Code:
[textView.text stringByReplacingOccurancesOfString:@"I will be right back" WithString:@"BRB];
It looks something like that anyway, I think it's what you're looking for.

Tom
Can you give me like the full code. Like what would I use and all that? That would be great bro!
__________________
- AppStoreMod
Youtube | Website | Twitter | Xcode Video Tutorials | AppStoreApps
AppStoreMod is offline   Reply With Quote
Old 12-31-2009, 12:06 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

No problem,
Code:
if ([textView.text rangeOfString:@"I will be right back"].location != NSNotFound){ //Check if textView has the string in it
  textView.text = [textView.text stringByReplacingOccurrencesOfString:@"I will be right back" withString:@"BRB"]; //If it does, replace it.
}
Tom
harrytheshark is offline   Reply With Quote
Old 12-31-2009, 12:11 PM   #5 (permalink)
Registered Member
 
AppStoreMod's Avatar
 
Join Date: Jul 2009
Location: Sacramento,CA
Posts: 90
Send a message via Skype™ to AppStoreMod
Default

Quote:
Originally Posted by harrytheshark View Post
No problem,
Code:
if ([textView.text rangeOfString:@"I will be right back"].location != NSNotFound){ //Check if textView has the string in it
  textView.text = [textView.text stringByReplacingOccurrencesOfString:@"I will be right back" withString:@"BRB"]; //If it does, replace it.
}
Tom
Actually nevermind! I got it! Thank you so much bro. You are freaking awesome!
__________________
- AppStoreMod
Youtube | Website | Twitter | Xcode Video Tutorials | AppStoreApps

Last edited by AppStoreMod; 12-31-2009 at 12:17 PM.
AppStoreMod is offline   Reply With Quote
Old 12-31-2009, 12:18 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yeah that's right, it will just replace "be right back".
On second thought, you don't even need to check for it. If it's there it will be replaced, if it's not, it won't. Simple.

I don't fully understand the second bit...
You just want to put "BRB" into a UIAlertView?

Also, try using the [ CODE ] tags (no spaces), it makes your code a lot easier to read

Tom
harrytheshark is offline   Reply With Quote
Old 12-31-2009, 12:20 PM   #7 (permalink)
Registered Member
 
AppStoreMod's Avatar
 
Join Date: Jul 2009
Location: Sacramento,CA
Posts: 90
Send a message via Skype™ to AppStoreMod
Default

Quote:
Originally Posted by harrytheshark View Post
Yeah that's right, it will just replace "be right back".
On second thought, you don't even need to check for it. If it's there it will be replaced, if it's not, it won't. Simple.

I don't fully understand the second bit...
You just want to put "BRB" into a UIAlertView?

Also, try using the [ CODE ] tags (no spaces), it makes your code a lot easier to read

Tom
Oh lol sorry. Actually I got it. Thanks so much dude! It worked just right. Thanks you! If it wasn't for you I would have never have finished my app.
__________________
- AppStoreMod
Youtube | Website | Twitter | Xcode Video Tutorials | AppStoreApps
AppStoreMod is offline   Reply With Quote
Old 12-31-2009, 12:25 PM   #8 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

No problem, glad I could help!

Tom
harrytheshark is offline   Reply With Quote
Reply

Bookmarks

Tags
convert, nsstring, objective c, raw c, shorten

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: 261
19 members and 242 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, DarkAn, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, MACralik, prchn4christ, Rudy, Speed
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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