views:

76

answers:

2

I have made some project When people put a keyword into UITextfield and click the button--->then my app will retrieve data from web-site database.

But I have spent so much time to find out what is wrong because it did not work look at the code here:

- (IBAction) btnClickMe_Clicked:(id)sender { 

    NSString *kw = s.text;  // <-----THIS IS THE UITextField

    NSURL *url = [NSURL URLWithString:@"http://www.xxx.com/index.php?keyword=",kw];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [iMessageLabel loadRequest:request];

}

Any one could help me i will be very happy thank you Alex

+2  A: 

You aren't putting the keyword into the string. You need something like this:

NSString *kw = s.text;
NSString *encodedkw =  [ky stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString *urlString = [NSString stringWithFormat: @"http://www.xxx.com/index.php?keyword=%@", encodedkw];

NSURL *url = [NSURL URLWithString:urlString];

Then look at how to use NSURLConnection to figure out how to put the data into the label.

carson
A: 

oh I really want to say, thank you so much for you valueable code... I really feel happy. Because i found the solution after u point to me. I change the plan ,,,instead of i will show the data in label, i show it in UIWebview by putting these 2 lines

NSURLRequest *request = [NSURLRequest requestWithURL:url];
[iMessageLabel loadRequest:request];

But I still don´t know and really want to know if i want to showw data in the UILabel how to do this ? I tried to look around there u point for me but seem complicate. I am very new with this.

Thanks for you help Alex