views:

170

answers:

1

I have am reading a twitter feed in my iPhone application and can do it correctly, but I'd like to evolve it in a way to detect if the whole NSString contains any URL or URLs and create a "link" that will open a UIWebView within the same application.

Can you guide me on how to perform this task?

-(void) setTextTwitter:(NSString *)text WithDate:(NSString*)date
{
    [text retain];
    [textTwitter release], textTwitter = nil;
    textTwitter = text;

    [date retain];
    [dateTwitter release], dateTwitter = nil;
    dateTwitter = date;

    [self setNeedsDisplay];
}
+1  A: 

Hey Cy,

Check out Craig Hockenberry's IFTweetLabel, which can be found here.

Or you can use the label provided by Three20 library, which can be found here.

Or the simplest solution: use UIWebView with dataDetectorTypes set to UIDataDetectorTypeLink.

Cheers, Paul

Pawel
Thanks for your reply Pawel, actually I am using Three20 library but can't find an API function to identify links... can you point me to it? That'd be great.
Cy.
As far as I remember you need to look for styleLabel (TTCatalog, StyledTextTableTestController, you'll be able to trace it from there). Cheers, Paul
Pawel