How to resume an XCode Download
Hi, This may not relevant to development directly but I could not find an answer for this over web.. may be someone experienced the same could help me here.. I have an internet connection with speed around 50-60kbps.. Last time it nearly took 12 hours to download the full iPhone SDK with 2.x Gig.. I had to continuously be with my MacBook.. As I know I cannot download just an update to my XCode.. The main problem is if I leave my MacBook and go to sleep then the download will fail.. From energy saver preferences I have ticked for wake up For Network Access also.. but still it failed twice.. worse thing was both times it was over 1 Gig download with my slow connection.. Is there any way I could resume a broken XCode download due to session expire.. I tried with both Safari and FF too.. Still same issue.. :( I would be really glad if someone could point me a way to resume an XCode download due to session expire.. I have tried automatic page refresh also using pagereboot.com.. no success .. :( Thank you and KInd Regards, Tharindu Madushanka ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running NSURLConnection from within an NSOperation?
I'm trying to run an NSURLConnection from an NSOperation. Apparently, it won't run. I know that NSURLConnection need a run loop. Does that mean I'll have to setup some kind of NSTime in my NSOperation and then call my run loop at regular intervals? Try using the synchronous version of NSURLConnection since you are launching it from within a NSOperation already- + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse**)response error:(NSError **)error Indeed sendSynchronousRequest: will work for a quick hack to talk to, say, your own server, but if you hope to some day have a real app which predictably handles real-world corner cases, well, let me quote what was told to me once: The NSErrors that you get from -sendSynchronousRequest: are not documented. For example, if you give it a wrong username/password combination, you get NSURLErrorUserCancelledAuthentication = -1012. Apparently this is an implementation detail, that when it receives an authentication challenge, it cancels. You're leaving the policy decisions to Apple instead of making them yourself, and since they are not documented, Apple may change them at any time. Ahh yes, the things you learn by posting a bad answer.. thanks for the additional insight. Greg ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
how to cancel / time out authorisation window through code
hi I am currently working on a Cocoa Application in which i pop up an authorisation window using AuthorizationCreate . if the user has not responded to it with a time say 60 seconds , i want to cancel/timeout the pop up window created by above authorisationCreate . how can i cancel / timeout the POP UP created by AuthorizationCreate API ? . Thanks in Advance P.Rajendran or Raju (for further details contact me ) Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
-[NSBundle preferredLocalizations]
Hi, Apple’s documentation states about -[NSBundle preferredLocalizations]: The localizations in the array are not returned in any particular order. This makes no sense, I’d expect this to be true for -[NSBundle localizations], why I’d expect -[NSBundle preferredLocalizations] to be implemented similar to the following: - (NSArray*) preferredLocalizations { return [NSBundle preferredLocalizationsFromArray:self.localizations]; } and the docu of -[NSBundle preferredLocalizationsFromArray:] says: These strings are ordered in the array according to the current user's language preferences. Could somebody with insight confirm whether this is a documentation bug? (Sure, I could check the actual order. But if the documentation is correct, the result would be meaningless for the future.) Thanks Kai ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXML and
Hi, Just to follow up on this as I'm still having problems have done some more testing and double-checked the XML specs. Yet again it seems that the NSXML classes are better at validating invalid XML when opening documents than when generating XML data. If you include the string ]] inside the stringValue of an NSXMLElement, the '' does not get escaped as it should according to the XML specs, and when you generate XML document data including such an element and then try to read it again, NSXMLDocument will fail and report the error: Sequence ']]' not allowed in content. Some sample code to demonstrate the issue: // Create an element containing some characters that should be escaped to create valid XML. NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@TeststringValue:@ ]] ] autorelease]; // Note how the '' and '' get escaped, but not the '' (even though it should do in the ']]' sequence). NSLog(@%@, element);// OUTPUT: Test lt; amp; ]] /Test // Now create an XML doc from the element and generate the data. NSXMLDocument*xmlDoc = [[[NSXMLDocumentalloc] initWithRootElement:element] autorelease]; NSData*data = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint]; // Check the doc and data: NSLog(@XML Doc: %...@\ndata: %@, xmlDoc, data);// Yep, they are non-nil, all fine. // Now load the data we created into an XML document. NSError *error; xmlDoc = [[NSXMLDocumentalloc] initWithData:data options:NSXMLNodePreserveWhitespaceerror:error]; if(xmlDoc == nil)// If it failed, try with tidy. xmlDoc = [[NSXMLDocumentalloc] initWithData:data options:NSXMLNodePreserveWhitespaceerror:error]; // Did it fail? if (xmlDoc == nil) { // Run the error. if (error) [[NSAlertalertWithError:error] runModal]; // Uh-oh... The error is: Line 2: Sequence ']]' not allowed in content. Because the '' should have been escaped. } In other words, although the NSXML classes will escape '' and '' correctly, they will not handle escaping '' at all - even when it occurs in the invalid (except when terminating CDATA) sequence ']]'. This then causes the NSXML classes to fail when re-loading the document they just created from the same data, because NSXML is more fussy about reading than writing. One the one hand, it is (sort of) fair enough to expect the user of these classes to ensure the string values are valid XML (even if it does mean every user of these classes having to be extra careful and become very familiar with the XML specs); on the other hand, how do I go about ensuring valid XML when this is user-generated data over which I have no control, and when the NSXML classes will tidy up the ampersands in any character entities I try to escape myself? At first, I thought I could just replace all occurrences of with gt; using NSString's -stringByReplacingOccurrencesOfString:withString:, e.g.: NSString *validXMLStr = [userStr stringByReplacingOccurrencesOfString:@ withString:@gt;]; NSXMLElement *element = [[NSXMLElement alloc] initWithName:@Text stringValue:validXMLStr]; Then, to restore it: NSString *value = [element stringValue]; userStr = [value stringByReplacingOccurrencesOfString:@gt; withString:@]; But of course, that won't work, because the gt; I place in my fixed string will become amp;gt; in the XML file. So, consider the user had written a string all about XML himself: It turns out that ']]' needs changing to ']]gt;' for valid XML... I then swap out the '' in this situation to 'gt;': It turns out that ']]gt;' needs changing to ']]gt;' for valid XML... I then pass it to the stringValue of an NSXMLElement which encodes it as: It turns out that ']]amp;gt;' needs changing to ']]amp;gt;' for valid XML... Then I read it back out, get its string value, and swap all occurrences of 'gt;' for '', and what we get on re-opening the file is: It turns out that ']]' needs changing to ']]' for valid XML... i.e. Not what the user wrote. An unlikely situation, I know, but not impossible and I have to account for it. In other words, if NSXMLElement won't escape the '' for me in situations where it should, how do I do it myself? Am I missing something obvious? Has anybody had to handle something similar? Many thanks and all the best, Keith - Original Message From: Jens Alfke j...@mooseyard.com To: Keith Blount keithblo...@yahoo.com Cc: glenn andreas gandr...@mac.com; cocoa-dev@lists.apple.com cocoa-dev@lists.apple.com Sent: Tue, February 9, 2010 9:37:46 PM Subject: Re: NSXML and On Feb 9, 2010, at 1:03 PM, Keith Blount wrote: Great, many thanks for the reply, and for the location of the information in the XML docs, that's very helpful. Unfortunately, it seems that the NSXML classes don't fix the '' in the ']]' case either, though: NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@TeststringValue:@ ]]] autorelease]; NSLog (@%@, element); The in ]] only needs to be escaped when it's inside a CDATA, I believe. (Since that string marks the end of a CDATA.)
Re: -[NSBundle preferredLocalizations]
On Feb 10, 2010, at 5:52 AM, Kai Brüning wrote: Could somebody with insight confirm whether this is a documentation bug? This is indeed an error in the documentation. Please file a bug against the documentation with the information you have provided. Douglas Davidson___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to resume an XCode Download
On Feb 10, 2010, at 2:28 AM, Tharindu Madushanka wrote: Is there any way I could resume a broken XCode download due to session expire.. I also have a slow connection. I have never been able to resume a broken XCode download. The only solution I have found is making sure your computer stays awake during the entire download. --Richard ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running NSURLConnection from within an NSOperation?
On 2010 Feb 10, at 01:43, Greg Reichow wrote: the things you learn by posting a bad answer. -sendSynchronousRequest: is not necessarily a bad answer, Greg. In some situations it is adequate, and then it is the correct choice due to its simplicity. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to resume an XCode Download
On Feb 10, 2010, at 9:45 AM, Richard Somers wrote: On Feb 10, 2010, at 2:28 AM, Tharindu Madushanka wrote: Is there any way I could resume a broken XCode download due to session expire.. I also have a slow connection. I have never been able to resume a broken XCode download. The only solution I have found is making sure your computer stays awake during the entire download. --Richard I don't know why this is such a mystery. Just go to the Energy Save panel in System Preferences and set the computer to never sleep. You can set the screen to sleep if you wish. HTH, Phil ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to resume an XCode Download
My problem is that my ISPs use long-haul WiFi links that seem to go down fairly regularly (which is why I keep redundant ISPs). This make multi-hour downloads occasionally frustrating. Todd On Feb 10, 2010, at 9:00 AM, Philip Ershler wrote: On Feb 10, 2010, at 9:45 AM, Richard Somers wrote: On Feb 10, 2010, at 2:28 AM, Tharindu Madushanka wrote: Is there any way I could resume a broken XCode download due to session expire.. I also have a slow connection. I have never been able to resume a broken XCode download. The only solution I have found is making sure your computer stays awake during the entire download. --Richard I don't know why this is such a mystery. Just go to the Energy Save panel in System Preferences and set the computer to never sleep. You can set the screen to sleep if you wish. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Large queue of messages for another app
On Feb 9, 2010, at 10:47 PM, Trygve Inda wrote: 1) Apple Events... These are messy but I'd go there if it'd not have lost events. Bingo. This is a really typical use case. The 'odoc' AppleEvent does exactly what you want. Just use NSWorkspace or LaunchServices to tell the other app to open a group of documents. You shouldn't even need to use any AE code directly. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to resume an XCode Download
On Wed, Feb 10, 2010 at 11:45 AM, Richard Somers rsomers.li...@infowest.com wrote: On Feb 10, 2010, at 2:28 AM, Tharindu Madushanka wrote: Is there any way I could resume a broken XCode download due to session expire.. I also have a slow connection. I have never been able to resume a broken XCode download. The only solution I have found is making sure your computer stays awake during the entire download. When I'm in doubt, I will download the file to a server where I have ssh access, then rsync it over to my Mac. A well connected web host can often grab the file from Apple in just a couple of minutes, and rsync will of course resume anything, anywhere, any time. Mike ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to resume an XCode Download
On Wed, Feb 10, 2010 at 1:28 AM, Tharindu Madushanka tharindu...@gmail.com wrote: This may not relevant to development directly but I could not find an answer for this over web.. may be someone experienced the same could help me here.. Tools questions belong on the xcode-users list. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Is a good practice to alloc an object and defer the initialization to another object?
Hi, I would like to alloc an object and defer the initialization to another object, is a good practice? The reason is that I can alloc several types of objects but the init method have the same signature. Thanks. Jean ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data Issue with Binding
I'm having trouble with a Cocoa app built around an NSManagedObject model. Without getting too far into the weeds, there is a Player object: @class Program; @interface Player : NSManagedObject { } @property (nonatomic, retain) NSDate *DateOfBirth; @property (nonatomic, retain) NSString *FirstName; @property (nonatomic, retain) NSString *LastName; @property (nonatomic, retain) NSNumber *DraftClass; @property (nonatomic, retain) NSNumber *DraftPick; @property (nonatomic, assign) BOOL Retired; @property (nonatomic, retain) NSSet *PlaysFor; @property (nonatomic, retain) Program *School; @property (readonly) NSString *DisplayName; @end The NSSet * points to a second NSManagedObject model entity, RosterSpot. That PlaysFor relationship is a to-many (a Player can have played on several rosters). The app presents a list of Players in an NSTableView by leveraging an NSArrayController (Players). I have the details of each player presented in a set of fields next to that table based on the selection in Players. I also have a second, smaller NSTableView in which I'd like to present the RosterSpot data for that same selected Player. I've created a second NSArrayController and I've tried everything to get it to allow me to add RosterSpot data to the selected Player. I've tried to bind the Managed Object Context to the Players NSArrayController with Controller Key selection and the Model Key Plays For. I've tried setting the Content Set (under Content Controller) to Players.selection.PlaysFor. No luck. I can't seem to bind that RosterSpot information. The app compiles without complaint and I can add Players at will with their information displayed but when I try to add RosterSpot information, I get nothing. The addition is a simple NSButton that has its action set to the add: method of the second NSArrayController. I'm certain someone has done this and I'm just missing something. Appreciate any help. Regards, Matt ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Using NSKeyedArchiver to save and restore state on iPhone apps
As many of you know, saving and restoring complex navigation hierarchies on the iPhone can be a real chore. So, I had this brilliant idea of setting up my app delegate like this: applicationDidFinishLaunching if userdefaults contains an archived navcontroller unarchive controller and retain else load nib with controller and retain add navcontroller view to window applicationWillTerminate archive nav controller and save to user defaults and then make all of my view controllers NSCoding compliant In theory, the archived navcontroller should contain my complex view controller hierarchy and all of the related views, so this should work. However, when I unarchive and add to view to the window, the subviews rarely have all of their values set correctly despite being supposedly NSCoding compliant. (For example, I have a button that fails to have it's target and action set) Am I missing something here or is this just buggy NSCoding compliant code on apple's part? Thanks, Jason ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running NSURLConnection from within an NSOperation?
There is at least one iPhone example that users the URL Loading System with NSOperation. On Feb 9, 2010, at 4:12 PM, Laurent Daudelin wrote: I'm trying to run an NSURLConnection from an NSOperation. Apparently, it won't run. I know that NSURLConnection need a run loop. Does that mean I'll have to setup some kind of NSTime in my NSOperation and then call my run loop at regular intervals? Search the docs for (and I’m not being a smart *** here) “Lazy” It loads a document, and then loads the contents specified by that document using NSOperation ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is a good practice to alloc an object and defer the initialization to another object?
On Wed, Feb 10, 2010 at 5:27 AM, Giannandrea Castaldi g.casta...@gmail.com wrote: I would like to alloc an object and defer the initialization to another object, is a good practice? The reason is that I can alloc several types of objects but the init method have the same signature. No. You must always do [[Foo alloc] init]. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Issue with Binding
On Wed, Feb 10, 2010 at 9:26 AM, Matthew Miller mattmille...@mac.com wrote: @property (nonatomic, retain) NSDate *DateOfBirth; @property (nonatomic, retain) NSString *FirstName; @property (nonatomic, retain) NSString *LastName; @property (nonatomic, retain) NSNumber *DraftClass; @property (nonatomic, retain) NSNumber *DraftPick; @property (nonatomic, assign) BOOL Retired; @property (nonatomic, retain) NSSet *PlaysFor; @property (nonatomic, retain) Program *School; @property (readonly) NSString *DisplayName; These are not KVC-compliant property names. You must rename these with lowercase initial letters, like dateOfBirth, firstName, etc. I've created a second NSArrayController and I've tried everything to get it to allow me to add RosterSpot data to the selected Player. I've tried to bind the Managed Object Context to the Players NSArrayController with Controller Key selection and the Model Key Plays For. I've tried setting the Content Set (under Content Controller) to Players.selection.PlaysFor. No luck. I can't seem to bind that RosterSpot information. You're thrashing. Why would you bind the managedObjectContext binding to a selection? You need to bind it to the MOC in which you want to insert your managed objects. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Large queue of messages for another app
On Feb 9, 2010, at 10:47 PM, Trygve Inda wrote: 1) Apple Events... These are messy but I'd go there if it'd not have lost events. Bingo. This is a really typical use case. The 'odoc' AppleEvent does exactly what you want. Just use NSWorkspace or LaunchServices to tell the other app to open a group of documents. You shouldn't even need to use any AE code directly. —Jens Once the files are processed by the sub app, I need to send a properties NSDictionary back to the main app. This can't really be handled by an 'odoc' event - Are AppleEvents as likely to get lost as NSDistributedNotifications? Trygve ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is a good practice to alloc an object and defer the initialization to another object?
On Feb 10, 2010, at 5:27 AM, Giannandrea Castaldi wrote: I would like to alloc an object and defer the initialization to another object, is a good practice? The reason is that I can alloc several types of objects but the init method have the same signature. It's unusual, but I've done it once or twice. It looks like: id obj; if (.) obj = [Class1 alloc]; else obj = [Class2 alloc]; obj = [obj initWithFoo: bar:]; It's important that you reassign 'obj' to the value of the init call, since initializers are allowed to return a different object than the receiver, and the class-cluster design pattern takes advantage of this. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
On Feb 10, 2010, at 10:40 AM, Jason Bobier wrote: In theory, the archived navcontroller should contain my complex view controller hierarchy and all of the related views, so this should work. However, when I unarchive and add to view to the window, the subviews rarely have all of their values set correctly despite being supposedly NSCoding compliant. (For example, I have a button that fails to have it's target and action set) There's more to nib loading than just unarchiving views. I don't think this is unlikely to work. I don't think it should be necessary, either: it's a violation of MVC. The persistent data is the model; that's what you want to save. The views are configured at runtime to reflect the state of the model. One practical problem with your approach would be if you ever change the design of your view hierarchy in a future release. Now you have a complex schema-migration problem when existing users launch the new version of the app and load an obsolete view hierarchy. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Large queue of messages for another app
On Feb 10, 2010, at 12:03 PM, Trygve Inda wrote: Once the files are processed by the sub app, I need to send a properties NSDictionary back to the main app. This can't really be handled by an 'odoc' event - Any AppleEvent can send a reply containing structured data. Although you're right that LaunchServices isn't set up to relay the reply back to you, so you probably need to use the AE API to do the sending. Are AppleEvents as likely to get lost as NSDistributedNotifications? No, they're lossless. (While distributed notifications can fall on the floor if the target process's Mach message queue overflows.) —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
What classes have -init?
I think at times I've written things like [[NSMutableArray alloc] init] with no apparent ill effects, but now I notice that the docs for NSMutableArray and NSArray don't say that there is an init method. The NSObject docs say that an init method might raise an exception. Is there some other init rule that I've missed, or have I just gotten lucky? -- James W. Walker, Innoventive Software LLC http://www.frameforge3d.com/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What classes have -init?
On Feb 10, 2010, at 12:23 PM, James Walker wrote: I think at times I've written things like [[NSMutableArray alloc] init] with no apparent ill effects, but now I notice that the docs for NSMutableArray and NSArray don't say that there is an init method. The NSObject docs say that an init method might raise an exception. Is there some other init rule that I've missed, or have I just gotten lucky? When in doubt, remember to look at the super-class documentation: http://developer.apple.com/mac/library/documentation/cocoa/reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/2050-init All classes that inherit from NSObject (which means pretty much all of them) inherit NSObject's –init method, and that's assumed or implicit in the Array examples you referenced above . . . Cheers, . . . . . . . .Henry = iPhone App Development and Developer Education . . . Visit www.nonatomic-retain.com Mac OSX Application Development, Plus a Great Deal More . . . Visit www.trilithon.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
This is separate from my model. This is the restoration of the view and controller hierarchy that is expected of iPhone apps when they startup. Restoring this can be incredibly complex when you have lots of view controllers including nav controllers, tab bar controllers, and modal controllers all stacked up. All of these are NSCoding compliant, which means that if I archive it, I should be able to unarchive it and get the exact state back (subject to conditional archiving, etc...) as long as I archive a complete object graph. Clearly, if there are any connections in your nib that connect to proxy objects (or the file's owner), you'd have to restore them yourself since you aren't loading from the nib. Storing the version of the app that saved the hierarchy would solve any issues related to that. Note, I've written tons of code to manually restore the hierarchy for other apps, I'm just trying to be clever and to save myself a bunch of complex coding (that easily gets out of sync with how your hierarchies can be stacked) this time... :) Jason On Feb 10, 2010, at 3:12 PM, Jens Alfke wrote: On Feb 10, 2010, at 10:40 AM, Jason Bobier wrote: In theory, the archived navcontroller should contain my complex view controller hierarchy and all of the related views, so this should work. However, when I unarchive and add to view to the window, the subviews rarely have all of their values set correctly despite being supposedly NSCoding compliant. (For example, I have a button that fails to have it's target and action set) There's more to nib loading than just unarchiving views. I don't think this is unlikely to work. I don't think it should be necessary, either: it's a violation of MVC. The persistent data is the model; that's what you want to save. The views are configured at runtime to reflect the state of the model. One practical problem with your approach would be if you ever change the design of your view hierarchy in a future release. Now you have a complex schema-migration problem when existing users launch the new version of the app and load an obsolete view hierarchy. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is a good practice to alloc an object and defer the initialization to another object?
For this use case you can also use the fact that classes are objects. Something like the following: Class theClass = nil; if (.) theClass = [Class1 class]; else theClass = [Class2 class]; id obj = [[theClass alloc] initWithFoo: bar:]; Jesper Storm Bache On Feb 10, 2010, at 12:07 PM, Jens Alfke wrote: On Feb 10, 2010, at 5:27 AM, Giannandrea Castaldi wrote: I would like to alloc an object and defer the initialization to another object, is a good practice? The reason is that I can alloc several types of objects but the init method have the same signature. It's unusual, but I've done it once or twice. It looks like: id obj; if (.) obj = [Class1 alloc]; else obj = [Class2 alloc]; obj = [obj initWithFoo: bar:]; It's important that you reassign 'obj' to the value of the init call, since initializers are allowed to return a different object than the receiver, and the class-cluster design pattern takes advantage of this. —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: http://lists.apple.com/mailman/options/cocoa-dev/jsbache%40adobe.com This email sent to jsba...@adobe.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
On Wed, Feb 10, 2010 at 12:54 PM, Jason Bobier ja...@prismatix.com wrote: All of these are NSCoding compliant, which means that if I archive it, I should be able to unarchive it and get the exact state back (subject to conditional archiving, etc...) as long as I archive a complete object graph. Not true. You have no idea what other objects have references to the ones you've archives, and these external references might be crucial to the functionality of your object graph. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSArray (unique Items matching x)
I have an array of Dicts with two fields in each (for example) Name and City Given a Name, I'd like to find all unique Cities or vis-versa. iTunes seems to do this with the column browser... Eg when you select Classic Rock, it pulls up a list of Artists without duplicates in the list... And does it very fast. It seems like a Predicate is working here... When one clicks Classic Rock, that is added to the predicate as Genre=Classic Rock, but then how does it extract the list of Artists from the master array since it doesn't want duplicates? Is this something I can do with bindings? I need to be able to select a city and get all the unique matches but ignore duplicates... And pull the data into an array. Thanks, Trygve ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
On Feb 10, 2010, at 12:40 PM, Jason Bobier wrote: As many of you know, saving and restoring complex navigation hierarchies on the iPhone can be a real chore. So, I had this brilliant idea of setting up my app delegate like this: applicationDidFinishLaunching if userdefaults contains an archived navcontroller unarchive controller and retain else load nib with controller and retain add navcontroller view to window applicationWillTerminate archive nav controller and save to user defaults and then make all of my view controllers NSCoding compliant In theory, the archived navcontroller should contain my complex view controller hierarchy and all of the related views, so this should work. However, when I unarchive and add to view to the window, the subviews rarely have all of their values set correctly despite being supposedly NSCoding compliant. (For example, I have a button that fails to have it's target and action set) Am I missing something here or is this just buggy NSCoding compliant code on apple's part? You don't want to take this approach at all. The proper thing to do is to archive model data (as others have pointed out). Note that this will now also be faster too since it will be a much smaller data set. For nav-based apps, this set of data often includes a screen ID of what screen the user left off at. Upon app launch, you can basically just push whatever screen you need to on the nav controller's stack. This is exactly what I do in my own iPhone OS apps. I also have an infrastructure to pass an NSDictionary filled with parameters as users hop from screen to screen. This allowed me to do stuff like this: In MyScreenA... - (IBAction)someAction:(id)sender { NSDictionary* = parameters = ...; [self pushScreen:MyScreenBID withParameters:parameters animated:YES]; } If users exit the app while on Screen B, I simply store the fact that I was on that screen (and any other metadata I need to preserve selections, scroll position, etc.) Then, on app launch, if such a freeze-dried state exists, I ultimately build up a set of parameters just like I did in the action method above. Then push the appropriate screen with those parameters (and set animated flag to NO). This will give the appearance of the app launching directly to the screen the user left off. But, under the covers, this is what actually occurs on app launch: - app launch routines - nav controller created; main nib loaded and set as top view - code that senses you have a saved state - push appropriate view controller to go to last used screen All the standard nib-loading occurs and things just work. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[iPhone 3.1] navigationItem.backBarButtonItem weirdness
Hello, all ... I've a question about the UINavigationController backBarButtonItem property. I wanted to merely set my own image for the back button, instead of it using the title of the controller above in the hierarchy. So, this is what I did (yes this app is using Three20, but I don't think that's the reason): - (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query { if (self = [super initWithNavigatorURL:URL query:query]) { self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@backarrow.png] style:UIBarButtonItemStylePlain target:self action:@selector(back)] autorelease]; } return self; } - (void)back:(id)sender { } Now, this worked -- but I wasn't _expecting_ it to work. I was expecting that my back selector would be called, and I would have to tell the nav controller to pop. However, my back selector isn't called, and the back button _works_ like it always has. While i'm not in any way against freebees like this, i'm a bit concerned as to _why_ it works like this. Any explanation would be appreciated, explanations that actually edify me more so :-) Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone 3.1] navigationItem.backBarButtonItem weirdness
Hi John, your selector is missing colon: @selector(back:) for method: -(IBAction)back:(id)sender hth, regards, Peter Blazejewicz On Thu, Feb 11, 2010 at 1:10 AM, John Michael Zorko jmzo...@mac.com wrote: Hello, all ... I've a question about the UINavigationController backBarButtonItem property. I wanted to merely set my own image for the back button, instead of it using the title of the controller above in the hierarchy. So, this is what I did (yes this app is using Three20, but I don't think that's the reason): - (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query { if (self = [super initWithNavigatorURL:URL query:query]) { self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@backarrow.png] style:UIBarButtonItemStylePlain target:self action:@selector(back)] autorelease]; } return self; } - (void)back:(id)sender { } Now, this worked -- but I wasn't _expecting_ it to work. I was expecting that my back selector would be called, and I would have to tell the nav controller to pop. However, my back selector isn't called, and the back button _works_ like it always has. While i'm not in any way against freebees like this, i'm a bit concerned as to _why_ it works like this. Any explanation would be appreciated, explanations that actually edify me more so :-) Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/peter.blazejewicz%40gmail.com This email sent to peter.blazejew...@gmail.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
Yes, you have to account for any references into the unarchived graph that objects not included in the graph hold. In my case, this should be as simple as removing the navcontroller view from it's superview. Jason On Feb 10, 2010, at 4:19 PM, Kyle Sluder wrote: On Wed, Feb 10, 2010 at 12:54 PM, Jason Bobier ja...@prismatix.com wrote: All of these are NSCoding compliant, which means that if I archive it, I should be able to unarchive it and get the exact state back (subject to conditional archiving, etc...) as long as I archive a complete object graph. Not true. You have no idea what other objects have references to the ones you've archives, and these external references might be crucial to the functionality of your object graph. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTableView not supplying expected object type
I have a table view with 4 columns, connected to a conventional datasource. The first 3 columns are fully set up in IB to have text field cells with attached number formatters. The 4th column has a variable data type where the user indirectly chooses a data type and the code dynamically sets the column's dataCell to the appropriate type for editing it. For a numeric value, this is a text field cell with an attached NSNumberFormatter, just like the other columns. The problem I'm having is that when the user edits the value in this column, the object value passed to the datasource's method: - (void) tableView:(NSTableView*)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn*) aTableColumn row:(NSInteger) rowIndex; is a string, not an NSNumber. From the columns set up in IB, I get NSNumbers as expected. It's as if the formatter is getting bypassed, though I can see it is definitely having the correct effect going the other way - it formats the field properly. Obviously I'm missing something in the set-up of the cell, but what? The cell type is set by this method, invoked when the user indirectly chooses the data type (some irrelevant code removed): - (void)setOutputType:(int) aType { NSTableColumn* tc = [mBinsTable tableColumnWithIdentifier:@representedObjectValue]; [[tc headerCell] setTitle:[self columnTitleForDataType:aType]]; // the cell type must be set to be appropriate to the class of data expected from -representedObjectValue // for styles this is an image, colours = special colour cell, text and number = text cell, with attached formatter for numbers. NSCell* aCell = [self dataCellForDataType:aType]; [aCell setEditable:YES]; [aCell setEnabled:YES]; [tc setDataCell:aCell]; [mBinsTable reloadData]; } The cell is made here (other type cases removed): - (NSCell*) dataCellForDataType:(int) aType { NSCell* aCell = nil; switch( aType ) { default: break; case kBinOutputTypeValue: { aCell = [[NSTextFieldCell alloc] init]; NSNumberFormatter* formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; [formatter setFormat:@##0.00]; [aCell setFormatter:formatter]; [formatter release]; } break; } return [aCell autorelease]; } The table view uses a delegate, and overrides: - (NSCell*) tableView:(NSTableView*) tableView dataCellForTableColumn:(NSTableColumn*) tableColumn row:(NSInteger) row { #pragma unused(tableView) if( tableColumn == nil ) return nil; if( [[tableColumn identifier] isEqualToString:@representedObjectValue]) { if( row == mTempCellRow row != -1 mTempCell ) return mTempCell; } return [tableColumn dataCellForRow:row]; } The 'mTempCellRow' stuff is used to deal with one of the custom cell types, not this one - I've verified that it doesn't take the wrong branch and just calls -dataCellForRow: Finally, this is where I'm seeing the problem. This code includes a workaround that I have at present, but it's a band-aid. I'd rather it worked properly than need this: - (void)tableView:(NSTableView*)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn*) aTableColumn row:(NSInteger) rowIndex { #pragma unused(aTableView) NSString* ident = [aTableColumn identifier]; DKOBin* bin = [[mTransformer bins] objectAtIndex:rowIndex]; // for some reason the raw string is passed instead of a number created by the formatter. For the time // being deal with this by performing the conversion manually here. if([ident isEqualToString:@representedObjectValue]) { if([anObject isKindOfClass:[NSString class]] [self outputType] == kBinOutputTypeValue) { anObject = [NSNumber numberWithFloat:[anObject floatValue]]; } } [bin setValue:anObject forKey:ident]; } --Graham ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone 3.1] navigationItem.backBarButtonItem weirdness
Peter, Yeah, but I get no NSException when I press the back button -- it does what it's always done (which I want). Also, I added the colon and it still doesn't even try to call my selector. In short, it works -- but i'm not sure _why_ it works. Regards, John your selector is missing colon: @selector(back:) for method: -(IBAction)back:(id)sender Hello, all ... I've a question about the UINavigationController backBarButtonItem property. I wanted to merely set my own image for the back button, instead of it using the title of the controller above in the hierarchy. So, this is what I did (yes this app is using Three20, but I don't think that's the reason): - (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query { if (self = [super initWithNavigatorURL:URL query:query]) { self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@backarrow.png] style:UIBarButtonItemStylePlain target:self action:@selector(back)] autorelease]; } return self; } - (void)back:(id)sender { } Now, this worked -- but I wasn't _expecting_ it to work. I was expecting that my back selector would be called, and I would have to tell the nav controller to pop. However, my back selector isn't called, and the back button _works_ like it always has. While i'm not in any way against freebees like this, i'm a bit concerned as to _why_ it works like this. Any explanation would be appreciated, explanations that actually edify me more so :-) Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
Hey Ricky, I'm strictly attempting to archive the controllers and views hierarchy starting from the navcontroller. My data model is quite separate from all of this. I've often done similar things to what you recommend, but complex interfaces often include tab controllers, nav controllers, modal views, etc..., storing the precise order of all of these along with the related metadata of all of the controls is a pain and prone to error. This idea came about because I was annoyed at having to do it again and realized that everything that I wanted to store was NSCoding compliant, which means that it should be archivable. It appears that some of the NSCoding compliant objects aren't completely restorable tho. :-/ Jason On Feb 10, 2010, at 4:53 PM, Ricky Sharp wrote: On Feb 10, 2010, at 12:40 PM, Jason Bobier wrote: You don't want to take this approach at all. The proper thing to do is to archive model data (as others have pointed out). Note that this will now also be faster too since it will be a much smaller data set. For nav-based apps, this set of data often includes a screen ID of what screen the user left off at. Upon app launch, you can basically just push whatever screen you need to on the nav controller's stack. This is exactly what I do in my own iPhone OS apps. I also have an infrastructure to pass an NSDictionary filled with parameters as users hop from screen to screen. This allowed me to do stuff like this: In MyScreenA... - (IBAction)someAction:(id)sender { NSDictionary* = parameters = ...; [self pushScreen:MyScreenBID withParameters:parameters animated:YES]; } If users exit the app while on Screen B, I simply store the fact that I was on that screen (and any other metadata I need to preserve selections, scroll position, etc.) Then, on app launch, if such a freeze-dried state exists, I ultimately build up a set of parameters just like I did in the action method above. Then push the appropriate screen with those parameters (and set animated flag to NO). This will give the appearance of the app launching directly to the screen the user left off. But, under the covers, this is what actually occurs on app launch: - app launch routines - nav controller created; main nib loaded and set as top view - code that senses you have a saved state - push appropriate view controller to go to last used screen All the standard nib-loading occurs and things just work. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data: Insert, Fetch, Re-Fetch. Same Object?
I've always wondered if I insert a managed object, then later fetch it repeatedly from the same managed object context, do I get the same object every time? (Assume that there is only one object which matches the given predicate.) This may be important if I want to, say, set an instance variable value. So I just wrote a little experiment, using an in-memory store, and found that the answer is yes, even if I run a run loop and fetch on a timer. Is this expected, or is this an implementation detail which Apple may change at any time? Thanks, Jerry CONSOLE OUTPUT: Inserted: Foo 0x1e0e960 name=Murphy ivar=Squawk First Fetched: Foo 0x1e0e960 name=Murphy ivar=Squawk Second Fetched: Foo 0x1e0e960 name=Murphy ivar=Squawk Delay Fetched: Foo 0x1e0e960 name=Murphy ivar=Squawk Delay Fetched: Foo 0x1e0e960 name=Murphy ivar=Squawk Delay Fetched: Foo 0x1e0e960 name=Murphy ivar=Squawk ... CODE (A Cocoa Tool Project): #import Foundation/Foundation.h #import CoreData/CoreData.h @interface Foo : NSManagedObject { NSString* m_ivar ; } @property (copy) NSString* ivar ; @end @implementation Foo @synthesize ivar = m_ivar ; - (void)dealloc { [m_ivar release] ; [super dealloc] ; } - (NSString*)description { return [NSString stringWithFormat: @Foo %p name=%@ ivar=%@, self, [self valueForKey:@name], [self ivar]] ; } @end // Note: This function returns a retained, not autoreleased, instance. NSManagedObjectModel *getStaticManagedObjectModel() { static NSManagedObjectModel *mom = nil; if (mom != nil) { return mom; } mom = [[NSManagedObjectModel alloc] init]; NSEntityDescription *fooEntity = [[NSEntityDescription alloc] init]; [fooEntity setName:@Foo]; [fooEntity setManagedObjectClassName:@Foo]; [mom setEntities:[NSArray arrayWithObject:fooEntity]]; NSMutableArray* properties = [[NSMutableArray alloc] init] ; NSAttributeDescription *attributeDescription; // Add an attribute. (Copy this section to add more attributes.) attributeDescription = [[NSAttributeDescription alloc] init]; [attributeDescription setName:@name]; [attributeDescription setAttributeType:NSStringAttributeType]; [attributeDescription setOptional:YES]; [properties addObject:attributeDescription] ; [attributeDescription release] ; [fooEntity setProperties:properties]; [properties release] ; [fooEntity release] ; return mom; } // Note: This function returns a retained, not autoreleased, instance. NSManagedObjectContext *getStaticManagedObjectContext() { static NSManagedObjectContext *moc = nil; if (moc != nil) { return moc; } moc = [[NSManagedObjectContext alloc] init]; NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:getStaticManagedObjectModel()]; [moc setPersistentStoreCoordinator: coordinator]; [coordinator release] ; NSError *error; NSPersistentStore *newStore ; newStore = [coordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:error]; if (newStore == nil) { NSLog(@Store Configuration Failure\n%@, ([error localizedDescription] != nil) ? [error localizedDescription] : @Unknown Error); } return moc; } @interface DelayedFetcher : NSObject { } @end @implementation DelayedFetcher + (void)fetchFoo:(NSTimer*)timer { NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init]; NSManagedObjectContext *moc = getStaticManagedObjectContext() ; [fetchRequest setEntity:[NSEntityDescription entityForName:@Foo inManagedObjectContext:moc]]; NSArray* fetches = [moc executeFetchRequest:fetchRequest error:NULL] ; [fetchRequest release] ; Foo* delayFetchedFoo = [fetches objectAtIndex:0] ; NSLog(@ Delay Fetched: %@, delayFetchedFoo) ; } @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // Create Core Data stack NSManagedObjectModel *mom = getStaticManagedObjectModel(); NSManagedObjectContext *moc = getStaticManagedObjectContext(); // Insert a Foo and name it Murphy Foo* insertedFoo = [NSEntityDescription insertNewObjectForEntityForName:@Foo inManagedObjectContext:moc] ; [insertedFoo setValue:@Murphy forKey:@name] ; [insertedFoo setIvar:@Squawk] ; [moc processPendingChanges] ; [moc save:NULL] ; NSFetchRequest*
Re: NSXML and
Still working on this and still getting nowhere, so another question: Is there a way to prevent NSXMLElement converting '' into 'amp' so that I can resolve character entities myself in my own NSXMLElement category -init... method? To recap the problem, the NSXML classes change '' into 'lt;' and '' into 'amp;' (when in string value content), just as they should according to the XML specs. But they don't convert '' into 'gt;'. This is fine as the XML specs don't require this in most situations, but if '' appears in the string ']]' (when not ending CDATA) then it must be escaped - but Apple's NSXML classes don't do this, generating invalid XML that cannot be opened by NSXMLDocument in this situation. I tried creating my own -initWithName:validStringValue: method which did some jiggery-pokery and then called -initWithXMLString:, thinking that this wouldn't do any conversion, the idea being that I could force ']]' to appear as ']]gt;' myself by creating the XML string directly rather than going through -setStringValue. But no. If you try this: NSXMLElement *element = [[NSXMLElement alloc] initWithXMLString:@testgt;/test]; NSLog (@%@, element); The output is: test/test In other words, the NSXMLElement automatically *forces* any occurrences of 'gt;' to become '', no matter how you try to work around it. And this means that if the user has entered the string ']]' and you need to encode that in XML somewhere, then the NSXML classes force you to write invalid XML that cannot be read. I've also tried creating the element like this: element = [[NSXMLNode alloc] initWithKind:NSXMLElementKind options:NSXMLPreserveAll]; [element setName:@Test]; [element setObjectValue:@gt;]; But this comes out as: Textamp;gt;/Test Right now I'm thinking the only way around this is to nuke any occurrences of ']]' altogether, and just not allow this sequence to be written to file at all. It's unlikely the user will enter this string in the fields that get encoded to XML in my app, anyway, so it will probably never be an issue. But I can't count on that, and this isn't an ideal solution - I'd much rather just know that I can write valid XML by escaping necessary characters. So, if anyone has any ideas of how to encode ']]' as ']]gt;' in the string value of an NSXMLElement (without it becoming ']]amp;gt;), I'd be very grateful. I think I need to file a bug report on this, too. Many thanks and all the best, Keith --- ORIGINAL MESSAGE --- Just to follow up on this, yet again it seems that the NSXML classes are better at validating invalid XML when opening documents than when generating XML data. If you include the string ]] inside the stringValue of an NSXMLElement, the '' does not get escaped as it should according to the XML specs, and when you generate XML document data including such an element and then try to read it again, NSXMLDocument will fail and report the error: Sequence ']]' not allowed in content. Some sample code to demonstrate the issue: // Create an element containing some characters that should be escaped to create valid XML. NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@TeststringValue:@ ]] ] autorelease]; // Note how the '' and '' get escaped, but not the '' (even though it should do in the ']]' sequence). NSLog(@%@, element);// OUTPUT: Test lt; amp; ]] /Test // Now create an XML doc from the element and generate the data. NSXMLDocument*xmlDoc = [[[NSXMLDocumentalloc] initWithRootElement:element] autorelease]; NSData*data = [xmlDoc XMLDataWithOptions:NSXMLNodePrettyPrint]; // Check the doc and data: NSLog(@XML Doc: %...@\ndata: %@, xmlDoc, data);// Yep, they are non-nil, all fine. // Now load the data we created into an XML document. NSError *error; xmlDoc = [[NSXMLDocumentalloc] initWithData:data options:NSXMLNodePreserveWhitespaceerror:error]; if(xmlDoc == nil)// If it failed, try with tidy. xmlDoc = [[NSXMLDocumentalloc] initWithData:data options:NSXMLNodePreserveWhitespaceerror:error]; // Did it fail? if (xmlDoc == nil) { // Run the error. if (error) [[NSAlertalertWithError:error] runModal]; // Uh-oh... The error is: Line 2: Sequence ']]' not allowed in content. Because the '' should have been escaped. } In other words, although the NSXML classes will escape '' and '' correctly, they will not handle escaping '' at all - even when it occurs in the invalid (except when terminating CDATA) sequence ']]'. This then causes the NSXML classes to fail when re-loading the document they just created from the same data, because NSXML is more fussy about reading than writing. One the one hand, it is (sort of) fair enough to expect the user of these classes to ensure the string values are valid XML (even if it does mean every user of these classes having to be extra careful and become very familiar with the XML specs); on the other hand, how do I go about ensuring valid XML when this is user-generated data over which I have no control, and when the
NSTextField restriction
Hi, I have a NSTextField outlet, and I'd like to limit the input to: 1) only upper case alpha characters2) must be two characters Any idea how to achieve this? Thanks, Angelo ___ YM - 離線訊息 就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。 http://messenger.yahoo.com.hk ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField restriction
On 11/02/2010, at 11:55 AM, Angelo Chen wrote: I have a NSTextField outlet, and I'd like to limit the input to: 1) only upper case alpha characters2) must be two characters Any idea how to achieve this? Thanks, Make a custom subclass of NSFormatter and attach it to the field. --Graham ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data: Insert, Fetch, Re-Fetch. Same Object?
On Feb 10, 2010, at 4:44 PM, Jerry Krinock wrote: I've always wondered if I insert a managed object, then later fetch it repeatedly from the same managed object context, do I get the same object every time? Yes, basically. There is only going to be one in-memory object at a time that represents the same managed object. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArray (unique Items matching x)
On Feb 10, 2010, at 1:45 PM, Trygve Inda wrote: iTunes seems to do this with the column browser... Eg when you select Classic Rock, it pulls up a list of Artists without duplicates in the list... And does it very fast. But keep in mind that iTunes is a Carbon app, not Cocoa. It seems like a Predicate is working here... When one clicks Classic Rock, that is added to the predicate as Genre=Classic Rock, but then how does it extract the list of Artists from the master array since it doesn't want duplicates? You're asking about iTunes' implementation, which we have no idea about. It seems to use some kind of custom database. What you're describing is a typical sort of database query (in SQL it would be like select distinct artist from ...). At a low level, in your code you could use an NSMutableSet to collect together the artist results, which would remove duplicates. I'm sure this would get awkward to work with, though. Basically I think you're running into the limitations of your very simple data structure. You could come up with something more complex, or you could start using CoreData and let it manage the data storage and querying for you. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArray (unique Items matching x)
You can do this using Key Value Coding, specifically using the collection operators like @distinctUnionOfSets etc. -Steven On Wed, Feb 10, 2010 at 9:11 PM, Jens Alfke j...@mooseyard.com wrote: On Feb 10, 2010, at 1:45 PM, Trygve Inda wrote: iTunes seems to do this with the column browser... Eg when you select Classic Rock, it pulls up a list of Artists without duplicates in the list... And does it very fast. But keep in mind that iTunes is a Carbon app, not Cocoa. It seems like a Predicate is working here... When one clicks Classic Rock, that is added to the predicate as Genre=Classic Rock, but then how does it extract the list of Artists from the master array since it doesn't want duplicates? You're asking about iTunes' implementation, which we have no idea about. It seems to use some kind of custom database. What you're describing is a typical sort of database query (in SQL it would be like select distinct artist from ...). At a low level, in your code you could use an NSMutableSet to collect together the artist results, which would remove duplicates. I'm sure this would get awkward to work with, though. Basically I think you're running into the limitations of your very simple data structure. You could come up with something more complex, or you could start using CoreData and let it manage the data storage and querying for you. —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: http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com This email sent to steven.degu...@gmail.com -- Steven Degutis http://www.thoughtfultree.com/ http://www.degutis.org/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data: Insert, Fetch, Re-Fetch. Same Object?
On 2010 Feb 10, at 18:05, Jens Alfke wrote: I've always wondered if I insert a managed object, then later fetch it repeatedly from the same managed object context, do I get the same object every time? Yes, basically. There is only going to be one in-memory object at a time that represents the same managed object. It certainly seems to be sensible, but I just wish someone could find such documentation. I can't. In the last few minutes here, I improved my demo to test an sqlite store as well as an in-memory store, and also I setStalenessInterval to 0 and threw in some -refreshObject:mergeChanges:NO and more saves. The only difference I found was that, while the in-memory store fetches the same object that you inserted, the sqlite store does not, although subsequent fetches return the same object. Can anyone guarantee this? I would imagine that, even though it's not documented, Apple must realize that if they were ever to change this behavior, it would probably break alot of apps which have been relying on it without the designers realizing this. Would Apple ever ever do anything like that? Jerry REVISED CONSOLE OUTPUT: Using sqlite store at /Users/jk/Desktop/FooTest.sqlite Inserted: Foo 0x30022c0 name=Murphy ivar=BeenInserted First Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched Second Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched Delay Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched saved=1 Delay Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched saved=1 Using in-memory store Inserted: Foo 0x300c1a0 name=Murphy ivar=BeenFetched First Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched Second Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched Delay Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched saved=1 Delay Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched saved=1 REVISED DEMO PROJECT: #import Foundation/Foundation.h #import CoreData/CoreData.h @interface Foo : NSManagedObject { NSString* m_ivar ; } @property (copy) NSString* ivar ; @end @implementation Foo @synthesize ivar = m_ivar ; - (void)dealloc { [m_ivar release] ; [super dealloc] ; } - (NSString*)description { return [NSString stringWithFormat: @Foo %p name=%@ ivar=%@, self, [self valueForKey:@name], [self ivar]] ; } @end // Note: This function returns a retained, not autoreleased, instance. NSManagedObjectModel *getStaticManagedObjectModel() { static NSManagedObjectModel *mom = nil; if (mom != nil) { return mom; } mom = [[NSManagedObjectModel alloc] init]; NSEntityDescription *fooEntity = [[NSEntityDescription alloc] init]; [fooEntity setName:@Foo]; [fooEntity setManagedObjectClassName:@Foo]; [mom setEntities:[NSArray arrayWithObject:fooEntity]]; NSMutableArray* properties = [[NSMutableArray alloc] init] ; NSAttributeDescription *attributeDescription; // Add an attribute. (Copy this section to add more attributes.) attributeDescription = [[NSAttributeDescription alloc] init]; [attributeDescription setName:@name]; [attributeDescription setAttributeType:NSStringAttributeType]; [attributeDescription setOptional:YES]; [properties addObject:attributeDescription] ; [attributeDescription release] ; [fooEntity setProperties:properties]; [properties release] ; [fooEntity release] ; return mom; } // Note: This function returns a retained, not autoreleased, instance. NSManagedObjectContext *getStaticManagedObjectContext() { static NSManagedObjectContext *moc = nil; if (moc != nil) { return moc; } moc = [[NSManagedObjectContext alloc] init]; NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:getStaticManagedObjectModel()]; [moc setPersistentStoreCoordinator: coordinator]; [coordinator release] ; NSError *error; NSPersistentStore *newStore ; #if 0 NSLog(@Using in-memory store) ; newStore = [coordinator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:error]; #else #warning USING_SQLITE_STORE NSString* path = NSHomeDirectory() ; path = [path stringByAppendingPathComponent:@Desktop] ; path = [path stringByAppendingPathComponent:@FooTest.sqlite] ; NSLog(@Using sqlite store at %@, path) ; NSURL* url = [NSURL fileURLWithPath:path] ; newStore = [coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:nil
[MEET] CocoaHeads-NYC tomorrow (Thursday) night
Marc van Olmen will give a talk entitled Introduction to NSOperation. As usual: (1) Please feel free to bring questions, code, and works in progress. We have a projector and we like to see code and try to help. (2) We'll have food and beer afterwards. (3) If there's a topic you'd like presented, let us know. (4) If *you'd* like to give a talk, let me know. Thursday, February 11 6:00 - 8:00 Downstairs at Tekserve, on 23rd between 6th and 7th http://tekserve.com/about/hours.php for directions and map Everyone's welcome. Just tell the person at the front you're there for CocoaHeads. Hope to see you there! --Andy ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArray (unique Items matching x)
You can do this using Key Value Coding, specifically using the collection operators like @distinctUnionOfSets etc. -Steven On Wed, Feb 10, 2010 at 9:11 PM, Jens Alfke j...@mooseyard.com wrote: On Feb 10, 2010, at 1:45 PM, Trygve Inda wrote: iTunes seems to do this with the column browser... Eg when you select Classic Rock, it pulls up a list of Artists without duplicates in the list... And does it very fast. But keep in mind that iTunes is a Carbon app, not Cocoa. It seems like a Predicate is working here... When one clicks Classic Rock, that is added to the predicate as Genre=Classic Rock, but then how does it extract the list of Artists from the master array since it doesn't want duplicates? You're asking about iTunes' implementation, which we have no idea about. It seems to use some kind of custom database. What you're describing is a typical sort of database query (in SQL it would be like select distinct artist from ...). At a low level, in your code you could use an NSMutableSet to collect together the artist results, which would remove duplicates. I'm sure this would get awkward to work with, though. Basically I think you're running into the limitations of your very simple data structure. You could come up with something more complex, or you could start using CoreData and let it manage the data storage and querying for you. Many thanks... It seems @distinctUnionOfSets will work nicely here. Cheers, Trygve ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using NSKeyedArchiver to save and restore state on iPhone apps
On Feb 10, 2010, at 4:38 PM, Jason Bobier wrote: This idea came about because I was annoyed at having to do it again and realized that everything that I wanted to store was NSCoding compliant, which means that it should be archivable. It appears that some of the NSCoding compliant objects aren't completely restorable tho. :-/ User interface objects support NSCoding in order to be archived in nib files. It’s not sufficient, however, to establish all of the outlet, action (and for Cocoa, binding) connections in a nib file, nor to invoke -awakeFromNib. There may also be some classes that don’t support NSCoding at all that can be referenced by a nib file, such as Cocoa’s NSWindow class. That’s why you don’t load nib files using NSKeyedUnarchiver, but instead by using one of the methods on NSBundle (or for Cocoa, NSNib). — Chris ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[MODERATOR] Re: How to resume an XCode Download
You’re correct. This isn’t relevant to development. And as a result it doesn’t belong here. Perhaps the xcode-users list might be more appropriate. On Feb 10, 2010, at 4:28 AM, Tharindu Madushanka wrote: This may not relevant to development directly but I could not find an answer for this over web.. may be someone experienced the same could help me here.. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Find in a WebKit view?
Is there any way to add support for the normal Cocoa Find functionality in a WebKit view? Failing that, is there any other way to get search functionality in a WebKit view? I want to do some in-app documentation, and Apple's Help system is so bad I've finally given up on that (floating window!?!), but without being able to search the web page, it is a bit limited. Ideally 10.5+, but I'd accept a 10.6+ solution. Thanks, Peter. -- Keyboard Maestro 4.0.2 now released! Brand new interface! Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac http://www.stairways.com/ http://download.stairways.com/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What classes have -init?
True. But most classes have designated initializers that configure the class properly. They should be documented, although typically they’re used for subclassing the class. On Feb 10, 2010, at 3:49 PM, Henry McGilton (Boulevardier) wrote: On Feb 10, 2010, at 12:23 PM, James Walker wrote: I think at times I've written things like [[NSMutableArray alloc] init] with no apparent ill effects, but now I notice that the docs for NSMutableArray and NSArray don't say that there is an init method. The NSObject docs say that an init method might raise an exception. Is there some other init rule that I've missed, or have I just gotten lucky? When in doubt, remember to look at the super-class documentation: http://developer.apple.com/mac/library/documentation/cocoa/reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/2050-init All classes that inherit from NSObject (which means pretty much all of them) inherit NSObject's –init method, and that's assumed or implicit in the Array examples you referenced above . . . ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone 3.1] navigationItem.backBarButtonItem weirdness
well here's what the documentation has to say about the backBarButtonItem property you are trying to set. When this item is the back item of the navigation bar—when it is the next item below the top item—it may be represented as a back button on the navigation bar. Use this property to specify the back button. The target and action of the back bar button item you set should be nil. The default value is a bar button item displaying the navigation item’s title. Did you read it, you should always have a peek at the documentation when something does something you didn't expect. The target and action of the back bar button item you set should be nil From that I assume that, on setting the back bar button item, the navigation controller sets a method on itself as the recipient of the action and whatever you set, it throws away. That makes sense, the back button item should go back, that's the expected behaviour and if anyone wants to do something custom, you have delegate methods for that which the nav controller calls for you. Might be nice if the framework asserted on stuff like this, actually there are quite a lot of cases in which it does, this doesn't seem to be one of them. On 11-Feb-2010, at 8:10 AM, John Michael Zorko wrote: Hello, all ... I've a question about the UINavigationController backBarButtonItem property. I wanted to merely set my own image for the back button, instead of it using the title of the controller above in the hierarchy. So, this is what I did (yes this app is using Three20, but I don't think that's the reason): - (id)initWithNavigatorURL:(NSURL *)URL query:(NSDictionary *)query { if (self = [super initWithNavigatorURL:URL query:query]) { self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@backarrow.png] style:UIBarButtonItemStylePlain target:self action:@selector(back)] autorelease]; } return self; } - (void)back:(id)sender { } Now, this worked -- but I wasn't _expecting_ it to work. I was expecting that my back selector would be called, and I would have to tell the nav controller to pop. However, my back selector isn't called, and the back button _works_ like it always has. While i'm not in any way against freebees like this, i'm a bit concerned as to _why_ it works like this. Any explanation would be appreciated, explanations that actually edify me more so :-) Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org This email sent to r...@rols.org ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What classes have -init?
On Feb 10, 2010, at 12:23 PM, James Walker wrote: I think at times I've written things like [[NSMutableArray alloc] init] with no apparent ill effects, but now I notice that the docs for NSMutableArray and NSArray don't say that there is an init method. The NSObject docs say that an init method might raise an exception. Is there some other init rule that I've missed, or have I just gotten lucky? It's worthwhile keeping this in mind: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW3 Particularly: When you define a subclass you must be able to identify the designated initializer of the superclass and invoke it in your subclass’s designated initializer through a message to super. You must also make sure that inherited initializers are covered in some way. Applying that [conceptually] to NSArray, say, there's no actual luck involved. If 'init' is a designated initializer, it should be documented in the class reference and there's no problem. If not, then NSArray *must* ensure that calling it results in one of its real designated initializers being called, *or* must produce an error.___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is a good practice to alloc an object and defer the initialization to another object?
id obj; if (.) obj = [Class1 alloc]; else obj = [Class2 alloc]; obj = [obj initWithFoo: bar:]; -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[iPhone 3.1] NSInvocation on main thread?
Hello, all ... I'm using NSInvocation so I can pass multiple arguments to delegate methods. However, I also want these delegate methods to get called on the main thread. Is there a way that I can use NSInvocation to call the method it wraps on the main thread, like performSelectorOnMainThread? Regards, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com