nsurlconnection

NSURLConnection causes bad access crash

梦想与她 提交于 2019-12-10 17:24:40
问题 I have been fighting with this for the past 48 hours and searching all forums with no use. I am using NSURLConnection to asynchronously download a series of web files. It randomly crashes after downloading a few files, the number of which is not fixed. Please see the call stack below: #0 0x35b634f4 in objc_msgSend #1 0x3527c2ca in CFEqual #2 0x3532e750 in __CFBasicHashStandardEquateKeys #3 0x35330514 in ___CFBasicHashFindBucket_Linear #4 0x3527c07c in CFBasicHashFindBucket #5 0x3527bf5c in

Get NSURLConnection response (from a helper class) inside method of a different class

左心房为你撑大大i 提交于 2019-12-10 16:29:12
问题 I have a class, "WebAPI", that handles all web API calls, the class uses NSURLConnection through its asynchronous delegate-based calls. Whenever an object needs to communicate with the web API it will use an instance of WebAPI and call the required method as shown below in the case of signing in I make the folowing call from the AppDelegate: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { WebAPI *webAPI = [[WebAPI alloc] init]; [webAPI performLoginWithUserName:@"test1

Swift - Return data from NSURLSession when sending POST request

限于喜欢 提交于 2019-12-10 15:58:05
问题 I can send a POST request in Swift using the below code func post() -> String{ let request = NSMutableURLRequest(URL: NSURL(string: "http://myserverip/myfile.php")!) request.HTTPMethod = "POST" let postString = "data=xxxxxxx" request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding) let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in if error != nil { println("error=\(error)") return } println("response = \(response)") let responseString

Updating an NSmenu from an asynchronous NSURLConnection

回眸只為那壹抹淺笑 提交于 2019-12-10 15:39:27
问题 I am writing a little systray application that fetches data from an API and updates its menu accordingly, and am having trouble with updating the menu while it's open. I don't even know where to start, so let's start with the beginning. I have a custom PNLinksLoader class whose responsibility is to fetch the data and parse it: - (void)loadLinks:(id)sender { // instance variable used by the NSXMLParserDelegate implementation to store data links = [NSMutableArray array]; [NSURLConnection

NSURLConnection Delegate Methods won't be called…can't figure it out and read a lot of posts

萝らか妹 提交于 2019-12-10 15:36:56
问题 I've got a class called BackendConnector which uses a NSURLConnection to call a SoapWebservice that is https. I found a lot of posts and tried to implement the delegate Methods regarding Authentication but they won't get called and after 6 hours in google I don't get what I've done wrong. Can someone please give me a hint why those 2 Delegate Methods won't get called? I set a breakpoint in each one, started my app with XCode in the simulator but still get the error and the Breakpoints don't

Multiple locks on web thread not allowed! Please file a bug. Crashing now

▼魔方 西西 提交于 2019-12-10 13:34:11
问题 i make a url-Request and waiting for the answer with I start the request, then waiting until synchronousOperationComplete=TRUE NSRunLoop *theRL = [NSRunLoop currentRunLoop]; while (!synchronousOperationComplete && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]); then I return the response all seems to be ok,i get the response and everything is working normal, but when I close the app i get: bool _WebTryThreadLock(bool), 0x227f40: Multiple locks on web thread not

Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found

情到浓时终转凉″ 提交于 2019-12-10 12:54:22
问题 I get this error when I try running the app on a device. I do not get this error when I run it on the simulator and the post request works fine. This is code snippet I have: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:300.f]; [request setHTTPMethod:@"POST"]; NSData* data = [paramString dataUsingEncoding:NSUTF8StringEncoding]; [request setHTTPBody:data]; [request setValue:@"application/x-www-form-urlencoded"

I am not able to parse xml data using GDataXML

≡放荡痞女 提交于 2019-12-10 12:23:19
问题 At first i have imported #import "GDataXMLNode.h" in .h file. Now this is my XML which i have to parse using GDataXML parser. <SiteStats> <visitor>1</visitor> <uniqueVisitor>1</uniqueVisitor> <orderCount>0</orderCount> <revenue>null</revenue> <conversionRate>0</conversionRate> <newProduct>3</newProduct> <outOfStockProduct>0</outOfStockProduct> </SiteStats> Now, one thing to notice is that my this xml is coming from web. So I have used NSUrlConnection delegate to retrieve xml data. - (void

Posting JSON data to server

点点圈 提交于 2019-12-10 11:46:34
问题 I am trying to post and JSON data to server. My JSON is: { “username”:”sample”, “password” : “password-1” } The way I am sending it to server is: NSError *error; NSString *data = [NSString stringWithFormat:@"{\"username\":\"%@\",\"password\":\"%@\"}",_textFieldUserName.text,_textFieldPasssword.text]; NSData *postData = [data dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSData *jsonData = [NSJSONSerialization JSONObjectWithData:postData options:0 error:&error];

Downloading multiple files writes same data to all files

点点圈 提交于 2019-12-10 11:42:40
问题 Attempting to download multiple files from an XML feed. There are several Categories and each category has an unknown amount of images. I create a subdirectory for each category, no problem. When I try to download each file to the respective category, every file is written with the same data for every image there is in the feed. I guess my question is how can I download 1 file at a time to the corresponding directory without overwriting all of the images with the same data? -(void