tags:

views:

17

answers:

1

Hi Guy's

I am having string at first the method calls with timestamp value nil and I am getting converted the string into url .next time when I click load more results button again the method calls with time stamp value assigned to it.but the url string is not converting into NSURL iam getting the null value into it.

-(NSMutableArray*)getTextMessagesArray:(NSString *)endTimestamp
 {
    printf("\n endtimestamp value...%s",[endTimestamp UTF8String]);
    NSString *urlString = @"http://123.237.186.221:8080/upload/textRequest.jsp";
    urlString = [urlString stringByAppendingString:@"?beginTimestamp="];
    urlString = [urlString stringByAppendingString:@"&endTimestamp="];
    if([endTimestamp length]>0)
    {
            urlString = [urlString stringByAppendingString:endTimestamp];
    }
    printf("\n &*(*(((urlString...%s",[urlString UTF8String]);
    NSURL* aUrl = [NSURL URLWithString:urlString];

    NSLog(@"url in appdelegaare in text...%@",aUrl);


    [textParser parseXMLFileAtURL:aUrl];
    textMessagesList = [textParser getTextMessagesList];
    printf("\n textMessagesList Count in appDelegate....%d",[textMessagesList count]);
    return textMessagesList;
  }

The result I am getting in console is:

 &*(*(((urlString...http://123.237.186.221:8080/upload/textRequest.jsp?endTimestamp=2010-10-08 16:20:47.0
 url in appdelegaare in text...(null)

Guy's can any one suggest me why this happening

Anyone's help will be much appreciated.

Thanks to all, Monish.

+1  A: 

Your problem is that valid URLs cannot contains spaces. You want to do something along the following lines:

NSString *escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// escapedUrlString should be "http://123.237.186.221:8080/upload/textRequest.jsp?endTimestamp=2010-10-08%2016:20:47.0"
NSURL *aUrl = [NSURL URLWithString:escapedUrlString];

This might be what you wanted.

Sedate Alien
Thanks alot.exactly the same thing I want.