views:

38

answers:

1

Hey All,

I am developing an app and the user has to enter the URL to access the information in the app. If the user forgets to enter the URL in a proper way, I want to prepend http:// and append soap.php to the URL text field. Is there any validation to be done for this or can I append using string methods? Also is there a way to allow HTTPS URL's..does it support or should I perform any validation for this too..please help me..

EDIT:

if ([[serverurlField.text substringToIndex:0]isEqualToString:@"http://"]) {
            syncDelegateImpl.serverURL = serverurlField.text;
        }
        else {
            syncDelegateImpl.serverURL = [NSString stringWithFormat:@"http:// %@",serverurlField.text,@"soap.php"];
        }
+1  A: 

[NSString rangeOfString:], [NSMutableString appendString:]and [NSString stringWithFormat:] are your friends.

tob
tob..thanks for the reply..I tried with stringWithFormat but it throws me a bad url message..is there any mistake in the way I tried..I edited my post..please have a look at it..thanks !!!
racharambola
Maybe the error comes from having a space between http:// and %@? Or maybe there's a / missing before soap.php?Where is the "bad url message" thrown?Please put a `NSLog(@"URL: %@", syncDelegateImpl.serverURL)` after the assignment and check if it looks right.
tob
yup I got it tob..thanks a lot
racharambola