Hi,

At one point in my code I need to recognize an URL to show in a different 
color. Pretty standard:

    NSURL *url = [NSURL URLWithString: aString];
    
    if (url)  // if url is created change color
    {
        NSAttributedString *linkString = [[NSAttributedString alloc] 
initWithString: aString
                                                                         
attributes: @{NSForegroundColorAttributeName: [UIColor blueColor]}];

        ...etc
    }

Works great, if aString starts with eg http:// it will be in blue; regular 
strings won't.


However, I noticed that strings that have the form P12345 also turn blue.  Any 
idea why that string would turn into an NSURL?  The url scheme is nil, and the 
path components just show P12345.  

(I could test above for if (url.scheme) to avoid this, but knowing why this 
happens would actually help me with other parts in my app).

Thanks,

- Koen.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to