How to prepare an NSURL from an NSString continaing international characters?

前端 未结 4 846
感情败类
感情败类 2020-12-11 07:59

I have to access a web server using a GET with international characters (Hebrew in my case but could be anything). So I make an NSString just fine

4条回答
  •  无人及你
    2020-12-11 08:28

    You can use NSURL directly without NSString:

    //.h file
    
    @interface NewsBrowser : UIViewController {
        UIWebView *webView;
        NSURL *NewsUrl;
    }
    
    @property (nonatomic, retain) IBOutlet UIWebView *webView;
    @property (nonatomic, assign) NSURL *NewsUrl;
    
    @end
    
    //.m file
    
    [webView loadRequest:[NSURLRequest requestWithURL:NewsUrl]];
    

    Just pass a NSURL from another view (using NewsUrl variable) to this view.

提交回复
热议问题