NSMutableURLRequest 乌木是什么么意思

全民编程开始了,你还在等什么?快来加入我们吧
已有账号,请
,或用以下账号登录
010-400-058-0010
& IOSpost请求实例
悬赏10分IOS post请求实例
老师大神们帮忙&NSString *urlstring = [NSString stringWithFormat:@&.tw/jpp/html/api/lxxjnnd.php?postdata=[{\&sg\&:\&3fe22fabf96c7b55f7622\&,\&job\&:\&9071\&,\&cell\&:\&\&,\&mac\&:\&abcd\&,\&lat\&:\&24.486160\&,\&lon\&:\&118.133083\&,\&rkey\&:\&e41ee201ef7c\&,\&mbrid\&:\&6630\&}]&];& & const char *str = [urlstring UTF8String];& & NSString *url = [NSString stringWithUTF8String:str];& & url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];& & aRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]];& & [aRequest setDidFinishSelector:@selector(requestDone:)];& & [aRequest setDidFailSelector:@selector(requestFailed:)];& & aRequest.delegate = self;& & [aRequest setRequestMethod:@&POST&];& & [aRequest setPostBody:imageData];& & [aRequest addRequestHeader:@&Content-Type& value:@&image/png&];//这里的value值 需与服务器端 一致& & [aRequest startAsynchronous];像这样得方式用post请求参数该怎么写,为什么图片上传没带进参数里面请老师和大神们帮帮忙谢谢
共 1 个回复
NSMutableURLRequest&*request&=&[[NSMutableURLRequest&alloc]initWithURL:url&cachePolicy:NSURLRequestUseProtocolCachePolicy&timeoutInterval:10];
[request&setHTTPMethod:@&POST&];//设置请求方式为POST,默认为GET
NSString&*str&=&@&type=q&xxx=yyyy&;//设置参数
NSData&*data&=&[str&dataUsingEncoding:NSUTF8StringEncoding];
[request&setHTTPBody:data];试试这个
才能回复哦……
3786个问题
<p class="more" style="color:#9个回答
<p class="more" style="color:#5个回答
<p class="more" style="color:#8个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
<p class="more" style="color:#个回答
北京优才创智科技有限公司    &2013 优才创智 京ICP备号iPhone开发笔记──WebView清除缓存方式
I actually think it may
retain cached information when you close out the UIWebView. I've
tried removing a UIWebView from my UIViewController, releasing it,
then creating a new one. The new one remembered exactly where I was
at when I went back to an address without having to reload
everything (it remembered my previous UIWebView was logged
So a couple of suggestions:
[[NSURLCache sharedURLCache] removeCachedResponseForRequest:NSURLRequest];
This would remove a cached response for a specific request. There
is also a call that will remove all cached responses for all
requests ran on the UIWebView:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
After that, you can try deleting any associated cookies with the
UIWebView:
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
& & if([[cookie domain] isEqualToString:someNSStringUrlDomain]) {
& & & & [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
Let me know where that gets you.
I had nearly the same problem. I wanted the webview cache to be
cleared, because everytime i reload a local webpage in an
UIWebView, the old one is shown. So I found a solution by simply
setting thecachePolicy&property
of the request. Use a&NSMutableURLRequest&to
set this property. With all that everything works fine with
reloading the UIWebView.
NSURL *url = [NSURL fileURLWithPath:MyHTMLFilePath];
&NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
&[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
&[self.webView loadRequest:request];
Hope that helps!
Don't disable caching completely, it'll hurt your app performance
and it's unnecessary. The important thing is to explicitly
configure the cache at app startup and purge it when necessary.
So in&application:DidFinishLaunchingWithOptions:&configure
the cache limits as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
& & int cacheSizeMemory = 4*1024*1024; // 4MB
& & int cacheSizeDisk = 32*1024*1024; // 32MB
& & NSURLCache *sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
& & [NSURLCache setSharedURLCache:sharedCache];
& & // ... other launching code
Once you have it properly configured, then when you need to purge
the cache (for example inapplicationDidReceiveMemoryWarning&or
when you close a&UIWebView)
[[NSURLCache sharedURLCache] removeAllCachedResponses];
and you'll see the memory is recovered. I blogged about this issue
You can disable the caching by doing the following:
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 乌木是什么 的文章

 

随机推荐