Web Search & Regular Expression Example
iPhone Code
+ 0 likes
Please Register to submit score.
| Average Score | 0.0 (of 0 scores) |
| Date Added | Mar 07, 2009 |
| Last Updated | Mar 07, 2009 |
| Tags | hawkee iphone regex search snippet uiwebview |
Introduction

This expands on a very basic Cocoa Touch example by Matt Long:
http://www.cimgf.com/2008/10/01/cocoa-touch-tutorial-iphone-application-example/
First complete his instructions. He's got a video that makes the process very clear.
After you've completed his tutorial you need to go to Basic_iPhone_AppAppDelegate.h and add a UIWebView for the search results:
| Code: |
| IBOutlet UIWebView *web; |
Feel free to remove the Label as it isn't necessary for this example.
Next you need to return to the Interface Builder by double clicking MainWindow.xib under Resources. Here you can delete the Label and drag a UIWebView into place as seen here:

Be sure to connect it to your "web" IBOutlet with a control click as you did in the original tutorial.
Next you'll need to download and include the RegexKitLite library. Add RegexKitLite.h and RegexKitLite.m to your Classes folder and follow these steps to add a linker flag to make the library work properly:
Project > Edit Active Target
Select the "Build" tab
Find "Other Linker Flags"
Add "-licucore" to the value column
Finally use the following snippet to replace the "click" IBAction you created in the example code:
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 7:52 pm
Posted on Mar 7, 2009 7:52 pm
Wow, this is very neat.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 7:53 pm
Posted on Mar 7, 2009 7:53 pm
Now you just need OS X and Xcode and you'll be ready to go.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 7:58 pm
Posted on Mar 7, 2009 7:58 pm
This is irrelevant, sorry, but is it me or did Hawkee's snippet "style" change?
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 8:08 pm
Posted on Mar 7, 2009 8:08 pm
Yes, I just posted about that on my profile.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 9:43 pm
Posted on Mar 7, 2009 9:43 pm
That looks nice wish i has a iphone :(
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 10:22 pm
Posted on Mar 7, 2009 10:22 pm
Wow kool, But as a hear from various ppl...Iphone is ok but really not what a lot thought it would be!! I'll stick to my samsung jack until the storm is out ..!!
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 7, 2009 11:29 pm
Posted on Mar 7, 2009 11:29 pm
this is the best way for me to learn a new language. i really appreciate you posting this.
as far as which phone is better, i'll stick with the iphone for now. heard a lot of bad things about the storm but it's supposedly better after firmware upgrades. it's a bummer that the g1 doesn't have multi touch, but how often is it really used? zooming in on images, maps, websites, blah. hopefully android will be on an att phone soon. then again, i may switch to verizon if a better phone comes their way.
as far as which phone is better, i'll stick with the iphone for now. heard a lot of bad things about the storm but it's supposedly better after firmware upgrades. it's a bummer that the g1 doesn't have multi touch, but how often is it really used? zooming in on images, maps, websites, blah. hopefully android will be on an att phone soon. then again, i may switch to verizon if a better phone comes their way.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Mar 16, 2009 6:21 pm
Posted on Mar 16, 2009 6:21 pm
I'm borrowing my friends mac very soon! can't wait to get onto the SDK and get going! :D
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 22, 2009 7:57 pm
Posted on Apr 22, 2009 7:57 pm
Hi. Thank for the tutorial... i am getting two errors in this code one is
..../WebSearchAppDelegate.m:48: error: 'RKLNoOptions' undeclared (first use in this function)
..../WebSearchAppDelegate.m:48: warning: 'NSString' may not respond to '-rangeOfRegex:options:inRange:capture:error:'
..../WebSearchAppDelegate.m:48: warning: (Messages without a matching method signature
..../WebSearchAppDelegate.m:48: error: incompatible types in assignment
..../WebSearchAppDelegate.m:57: warning: 'NSString' may not respond to '-rangeOfRegex:options:inRange:capture:error:'
..../WebSearchAppDelegate.m:57: error: incompatible types in assignment
Did anyone try this code???? Is it working for you guys....
Please help me.... It will help me in my project a lot.....
Thanks again for the tutorial..... :)
..../WebSearchAppDelegate.m:48: error: 'RKLNoOptions' undeclared (first use in this function)
..../WebSearchAppDelegate.m:48: warning: 'NSString' may not respond to '-rangeOfRegex:options:inRange:capture:error:'
..../WebSearchAppDelegate.m:48: warning: (Messages without a matching method signature
..../WebSearchAppDelegate.m:48: error: incompatible types in assignment
..../WebSearchAppDelegate.m:57: warning: 'NSString' may not respond to '-rangeOfRegex:options:inRange:capture:error:'
..../WebSearchAppDelegate.m:57: error: incompatible types in assignment
Did anyone try this code???? Is it working for you guys....
Please help me.... It will help me in my project a lot.....
Thanks again for the tutorial..... :)
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 22, 2009 8:32 pm
Posted on Apr 22, 2009 8:32 pm
Did you add RegexKitLite? RKLNoOptions is defined in RegexKitLite.h
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 22, 2009 8:51 pm
Posted on Apr 22, 2009 8:51 pm
I included the RegexKitLite.h/.m file..... I didnt include the RKLMatchEnumerator.h/.m . I did that. It is still giving the same errors. I cleaned the Targets and rebuild the code... Still the same errors....
Just to tell you I went through documentation for RegexKit framework and saw how to connect it and did those steps to like copying it in the target/link Binaries... Was I supposed to do that???
Thanks for such a fast reply. Appreciate it. :)
Just to tell you I went through documentation for RegexKit framework and saw how to connect it and did those steps to like copying it in the target/link Binaries... Was I supposed to do that???
Thanks for such a fast reply. Appreciate it. :)
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 22, 2009 9:43 pm
Posted on Apr 22, 2009 9:43 pm
Hmm, what version of Xcode are you using? Maybe this is a problem with the newer version.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 22, 2009 10:24 pm
Posted on Apr 22, 2009 10:24 pm
I am using Xcode Version 3.1.2
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 23, 2009 12:33 am
Posted on Apr 23, 2009 12:33 am
That's the version I got, so it should work. I think all I did for RegexKitLite was add those 4 files and add the -licucore value under "Other Linker Flags".
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 23, 2009 1:50 am
Posted on Apr 23, 2009 1:50 am
Followed all the steps as it is..... Did not go through the procedure I followed earlier... still getting the same errors..... Both the errors are in the matchedRange = .... statements. :(.
Didn't any one else get such errors???
Didn't any one else get such errors???
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 23, 2009 1:55 am
Posted on Apr 23, 2009 1:55 am
Maybe just try options:0 as that's really what RKLNoOptions represents.
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Apr 23, 2009 2:09 am
Posted on Apr 23, 2009 2:09 am
No.... I tried to put both the statements in comment also...(I know it was silly...) Application terminated because of unknown exception. I am trying to figure it out... The errors and warnings are about incompatible types.......
iPhone Snippet:
Web Search & Regular Expression Example
Posted on May 27, 2009 3:36 pm
Posted on May 27, 2009 3:36 pm
This work for the 2nd gen ipod touch?
iPhone Snippet:
Web Search & Regular Expression Example
Posted on May 27, 2009 3:56 pm
Posted on May 27, 2009 3:56 pm
Yea it should work for any iPhone or Touch on 2.x
iPhone Snippet:
Web Search & Regular Expression Example
Posted on Aug 10, 2009 8:25 pm
Posted on Aug 10, 2009 8:25 pm
Thanks for this! I just started on my 2nd app.. (first is in review and probably will be for another week at least, but I'll post an image if/when it gets approved) ...and I wanted to use regex but when I added the regexkitlite.h and .m files I got 13 errors, figured I did something wrong and almost gave up. Then I remembered you had a snippet posted and your walkthrough at the end saved me, thanks!












