NSURLConnection and 404
This works fine, but blocks my for 1 sec on a good day - who know how long if the net is slow: url = something/which/might/exist/or/not.gif data = [ NSData dataWithContentsOfURL: url options: mask error: outError ]; So I am trying to use NSURLConnection instead. Also works fine. Only: if my url does not exist, then the old method returned data = nil. Very good. Using NSURLConnection I always get some answer - either image data or a lengthy string like: HTML 4.0 Transitional//EN html head titleError 404 - Page not found/title /head body bgcolor=#00 [...] Is there a way to get just the status (in this case 404) without parsing the data? I looked at the NSURLConnection delegate methods, but did not find anything which looked appropriate. Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLConnection and 404
On Jun 9, 2013, at 5:35 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Is there a way to get just the status (in this case 404) without parsing the data? I looked at the NSURLConnection delegate methods, but did not find anything which looked appropriate. I do something like this: - (void) connectionDidFinishLoading:(NSURLConnection *)connection { NSString *xmlString = [[NSString alloc] initWithData: receivedData encoding: NSUTF8StringEncoding]; NSError *error = nil; if ([xmlString containsSubString: @DOCTYPE]) // the server gave an error in html format { error = [self serverErrorFromHTMLString: xmlString]; } else { // no 404, etc status, so we can parse NSXMLParser *parser = [[NSXMLParser alloc] initWithData: receivedData]; } // show alert with error if needed } - Koen. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLConnection and 404
Le 9 juin 2013 à 11:35, Gerriet M. Denkmann gerr...@mdenkmann.de a écrit : This works fine, but blocks my for 1 sec on a good day - who know how long if the net is slow: url = something/which/might/exist/or/not.gif data = [ NSData dataWithContentsOfURL: url options: mask error: outError ]; So I am trying to use NSURLConnection instead. Also works fine. Only: if my url does not exist, then the old method returned data = nil. Very good. Using NSURLConnection I always get some answer - either image data or a lengthy string like: HTML 4.0 Transitional//EN html head titleError 404 - Page not found/title /head body bgcolor=#00 [...] Is there a way to get just the status (in this case 404) without parsing the data? I looked at the NSURLConnection delegate methods, but did not find anything which looked appropriate. Gerriet. The NSConnectionDelegate protocol has a method that pass you the response: - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response You can test if the response is of type NSHTTPURLResponse (which should always be the case when you send an HTTP request), and then use the -[NSHTTPURLResponse statusCode] method to get the status. -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLConnection and 404
On 9 Jun 2013, at 16:54, Jean-Daniel Dupas devli...@shadowlab.org wrote: Le 9 juin 2013 à 11:35, Gerriet M. Denkmann gerr...@mdenkmann.de a écrit : This works fine, but blocks my for 1 sec on a good day - who know how long if the net is slow: url = something/which/might/exist/or/not.gif data = [ NSData dataWithContentsOfURL: url options: mask error: outError ]; So I am trying to use NSURLConnection instead. Also works fine. Only: if my url does not exist, then the old method returned data = nil. Very good. Using NSURLConnection I always get some answer - either image data or a lengthy string like: HTML 4.0 Transitional//EN html head titleError 404 - Page not found/title /head body bgcolor=#00 [...] Is there a way to get just the status (in this case 404) without parsing the data? I looked at the NSURLConnection delegate methods, but did not find anything which looked appropriate. Gerriet. The NSConnectionDelegate protocol has a method that pass you the response: - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response You can test if the response is of type NSHTTPURLResponse (which should always be the case when you send an HTTP request), and then use the -[NSHTTPURLResponse statusCode] method to get the status. Excellent! This is exactly what I was looking for. Thank you very much! Merci beaucoup! Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPopUpButtonCell - How To Get The Changed Value
On 2013 Jun 08, at 18:28, Chris Tracewell ch...@thinkcl.com wrote: I can't seem to make KVO work since it's an array in a dictionary inside an array. In the area of tables and bindings, there are typically a half dozen design patterns which should work but don't, and one that works. Binding to an array controller is generally the pattern that works. I think you need to replace that dictionary with a class that has properties which you can bind to. In the table column containing your popup cell, bind the Selected Object to the array controller with Controller Key = arrangedObjects, and Model Key Path = thatProperty. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UICollectionView with NSFetchedResultsController; compatible?
I just finished watching Marcus Zarra's NSFetchedResultsController presentation from iDeveloper.tv . At about 25 minutes into the presentation, Marcus says the NSFetchedResultsController only works well with table-view controllers. I had planned to use it with a collection-view, which is why I reviewed the presentation in the first place. What I'm looking for is more information on why it is not a good idea to mix these two classes. What are the issues or pitfalls, in combining the two? I did find think link to a project on GitHub where the author points out that: The trick is to queue the updates made through the NSFetchedResultsControllerDelegate until the controller finishes its updates. UICollectionView doesn't have the same beginUpdates and endUpdates that UITableView has to let it work easily with NSFetchedResultsController, so you have to queue them or you get internal consistency runtime exceptions. Is this the only issue or are there other reasons to avoid combining these two types of controllers? -Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLConnection and 404
On Jun 9, 2013, at 5:54 AM, Jean-Daniel Dupas devli...@shadowlab.org wrote: The NSConnectionDelegate protocol has a method that pass you the response: - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response You can test if the response is of type NSHTTPURLResponse (which should always be the case when you send an HTTP request), and then use the -[NSHTTPURLResponse statusCode] method to get the status. A much better solution than what I proposed! - Koen. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
error in using NSNumber's numberWithInt: method not flagged
Quite by chance, I stumbled on to what seems to be an error that ought to be caught by the compiler but wasn't. Here's an example: NSNumber *testNumber = [NSNumber numberWithInt:5]; int testInt = (int)testNumber; However, the value of testInt when running the above is wildly incorrect (as one would expect). The similar code NSNumber *testDouble = [NSNumber numberWithDouble:5.77]; double myDouble = (double)testDouble; is flagged with the error message Pointer cannot be cast to type 'double' , as it should be. I'm running OSX 10.7.5 with Xcode 4.6 and using LLVM (I presume). Should I file a bug report or is this a well-known anomaly that I've just come across? Boyd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: error in using NSNumber's numberWithInt: method not flagged
On Jun 9, 2013, at 1:26 PM, Boyd Collier bcolli...@cox.net wrote: Quite by chance, I stumbled on to what seems to be an error that ought to be caught by the compiler but wasn't. Here's an example: NSNumber *testNumber = [NSNumber numberWithInt:5]; int testInt = (int)testNumber; […snip…] Should I file a bug report or is this a well-known anomaly that I've just come across? Sitting on a runway right now, so I can't double-check the C spec, but I believe this is a consequence of C's use of integers for truth types. A pointer must be convertible to integer type, because it can be used in the form `if (expressionOfPointerType)`. It follows that casting to int must also be allowed. I'm not sure what the spec says about the actual value of the result. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: error in using NSNumber's numberWithInt: method not flagged
On Jun 9, 2013, at 1:32 PM, Kyle Sluder k...@ksluder.com wrote: On Jun 9, 2013, at 1:26 PM, Boyd Collier bcolli...@cox.net wrote: Quite by chance, I stumbled on to what seems to be an error that ought to be caught by the compiler but wasn't. Here's an example: NSNumber *testNumber = [NSNumber numberWithInt:5]; int testInt = (int)testNumber; […snip…] Should I file a bug report or is this a well-known anomaly that I've just come across? Sitting on a runway right now, so I can't double-check the C spec, but I believe this is a consequence of C's use of integers for truth types. A pointer must be convertible to integer type, because it can be used in the form `if (expressionOfPointerType)`. It follows that casting to int must also be allowed. I'm not sure what the spec says about the actual value of the result. Explicitly converting a pointer to an integer type (other than _Bool/bool) reinterprets the bit-representation of the pointer as an integer. There are a lot of low-level tricks you can then play with that. Of course, you need to use an integral type that's large enough to store the pointer value. Playing with the bit-representation of Objective-C pointers specifically is ill-advised because the implementation reserves the right to play its own games with object pointers (such as the optimized representation of integer values when boxed as NSNumbers on 64-bit platforms), but nonetheless this behavior is inherited from C and cannot really be changed. John. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: error in using NSNumber's numberWithInt: method not flagged
This is correct behavior. C allows casting between pointer and integer types. It’s used a lot for doing pointer arithmetic. (C’s ancestor BCPL didn’t even have separate integer and pointer types.) You might get an optional compiler warning if the integer type narrower than a pointer, but that’s about it. However, it makes no sense at all to cast between a pointer and a float, so that’s an error. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Suggested maximum size of NSCachesDirectory on iOS
Hi, on iOS, is there any documentation on how much space an app should use at most when storing things in the location returned by NSFileManagers's -URLsForDirectory: with NSCachesDirectory? Are there any hard numbers (like for example never more than 1/20th of the entire disk, or something like that)? I couldn't find the slightest hint. I have an app that potentially produces a lot of cached data (downloaded from the network). Caching is highly beneficial to its performance, so generally the bigger the cache the better. Still, filling the device up until it's maxed out doesn't seem a good thing to do. Also, there's no mention on when cached files will get deleted (in case space runs out). The only piece of documentation with respect to deletion I came across is that cache files *may* not survive an update of the app. However, the system surely will (have to) start deleting files before then if it runs out of space, no? Does anyone have any insights? Thanks! Regards Markus -- __ Markus Spoettl ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Search field in menu, like Help menu has
My OS X app programmatically creates a menu which is displayed in its (1) Dock Menu (2) Status Item (3) a menu which use can pop up anywhere via a global keyboard shortcut, which invokes -[NSMenu popUpMenuPositioningItem:atLocation:inView:] I would like to add a search field at the top of this menu, like the search field in the Help menu of any Cocoa app. At least in instance (3). In Apple's document Application Menu and Pop-up List Programming Topics [1], it is stated that A view in a menu item can receive all mouse events as normal, but keyboard events are not supported. But a search field certainly supports keyboard events! So how might Apple be doing that? Thanks, Jerry Krinock ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com