NSObjectController mapped to NSArrayController selection
Hi all! I have the following situation: NSArrayController which handles array of Core Data objects. Then I want to map it's selection (there can only be one selected at a time) to NSObjectController's contents and then use the object controller for binding to the view. I want to use the object controller as the entry point for the second nib, but I can't get it to work even in the same nib. This is how I figure: NSObjectController bindings (in IB): - Content Object (my NSArrayController) with controller key selection A label: - Value (the NSObjectController) with controller key content and model key name However the label shows nothing no matter what selection is there. NSArrayController's selection is properly updated - if I bind the label to it's selection.name directly it works. What am I missing? Thanks, Tom ___ 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: Autorotation for a subview
Eric, 1. Can’t you use autoresizingMask for all subviews? You can do pretty much automagic with it. Just let your Button hang to the lower and right borders. A view should not resize/reposition itself. 2. Don’t put the view of controller B into a view of controller A. Why not presentModalViewController:animated:? 3. is a question from me to the knowing: It seems that when didRotateFromInterfaceOrientation: is called, all views are still in the old orientation. Is this correct? If so I will file a bug because after it DID rotate the views should all have their new position / size. atze Am 23.12.2009 um 02:09 schrieb Eric E. Dolecki: I already stated (I believe) that I needed to redo the way this application is being constructed. In this way I'll have more direct access to subviews. I originally created another view controller with it's own nib and I was indeed loading it and using it as a subview to my main view. No leaks since it's removed itself from superview. In regards to the NSNotification, I look at that as a learning opportunity and not merely a way of throwing some code at a problem hoping it will make it work. I haven't ever used it before - I've only been part-timing iPhone apps for about 7 months now. It's fascinating and exciting and humbling when you're trying to do something and were unaware of the proper framework or methods to use. Eric On Tue, Dec 22, 2009 at 7:37 PM, mmalc Crawford mmalc_li...@me.com wrote: On Dec 22, 2009, at 3:37 pm, Matt Neuburg wrote: This sounds like a good time for the view to post an NSNotification. The subview can then respond to it. m. Sounds like overkill --- swatting mosquitoes with sledgehammers. An NSNotification is not a sledgehammer. And letting interested listeners know that a certain key moment in the lifetime of the application has been reached, is not a mosquito. Indeed, this is why something like UIApplicationDidFinishLaunchingNotification *is* a notification. Sometimes the delegate or subclass instance is not the only interested party; the moment where didRotateFromInterfaceOrientation: arrives might be such a case. Using a notification per se is not a sledgehammer. Setting up your own view to post notifications for this situation, however, almost certainly is (*insofar as it's possible to determine the OP's requirements, given the confused problem description...*). There is already a perfectly good mechanism for communicating changes about a device's orientation through an object that's in the best place to respond to such changes -- UIView*Controller*'s willAnimateRotationToInterfaceOrientation... et al. methods. On Dec 22, 2009, at 4:25 pm, Eric E. Dolecki wrote: I am interested in NSNotification as I haven't used that yet. It's not clear if you're trying to solve a problem or learn about iPhone OS programming in general. Unthinkingly chasing interesting API is not a particularly useful strategy for solving a problem. Per Henry's reply, you should properly describe what the task is you're trying to accomplish using terminology and conventions that will best help those trying to help you. Hint; this: - (IBAction) displayInfo:(id)sender { myInfoView = [[InfoViewController alloc] initWithNibName:@ InfoViewController bundle:[NSBundle mainBundle]]; myInfoView.view.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); [self.view addSubview:myInfoView.view]; } makes almost no sense. Using a view controller to instantiate a view to add as a subview of another view that is presumably managed by another view controller is not a supported pattern. You're also ignoring basic memory management guidelines, and will almost certainly be leaking both the view controller and its accompanying view. Adding notifications to this scenario will not end prettily. mmalc ___ 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: NSRuleEditor: Criteria for new row
I was able to fake it by subclassing a private method: - (void)_addOptionFromSlice:(id)slice ofRowType:(unsigned int)type { int rowIndex = [(NSRuleEditorViewSlice*)slice rowIndex]; NSArray *criteriaForRow = [self criteriaForRow:rowIndex]; NSArray *displayValuesForRow = [self displayValuesForRow:rowIndex]; self.template = [NSArray arrayWithObjects:criteriaForRow, displayValuesForRow, nil]; [super _addOptionFromSlice:slice ofRowType:type]; } - (void)insertRowAtIndex:(NSInteger)rowIndex withType:(NSRuleEditorRowType)rowType asSubrowOfRow:(NSInteger)parentRow animate:(BOOL)shouldAnimate { [super insertRowAtIndex:rowIndex withType:rowType asSubrowOfRow:parentRow animate:shouldAnimate]; NSArray *template = self.template; if (template != nil) { [self setCriteria:[template objectAtIndex:0] andDisplayValues:[template objectAtIndex:1] forRowAtIndex:rowIndex]; } } Pierre On Dec 23, 2009, at 12:37 AM, Peter Ammon wrote: On Dec 22, 2009, at 10:57 AM, Houdah - ML Pierre Bernard wrote: When I hit the + button on a row in NSRuleEditor, a new row is created. How can I take influence on the criteria used for that row. It seems NSRuleEditor defaults to selecting the first criterion sequentially from the list of possible values. I would much rather have the new row match the row where the + was clicked. Pierre Sorry, this isn't possible right now. - - - Houdah Software s. à r. l. http://www.houdah.com HoudahGeo: One-stop photo geocoding HoudahSpot: Powerful Spotlight frontend ___ 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: Are views active or inactive?
Rick Mann wrote: On Dec 22, 2009, at 19:51:03, Kyle Sluder wrote: On Tue, Dec 22, 2009 at 9:45 PM, Rick Mann rm...@latencyzero.com wrote: I'm listening for that notification. Sure is a clunky way to do things. I've never used a view framework that didn't tell views when they became active/inactive. Views don't become (in)active, windows do. Since there are plenty of things that might be interested in that (Window menu, controllers, views∑), it's done as a notification so all interested parties can listen for it. I'm not against the notification, I just think NSView should have an active property. Views do become inactive (look at any well-designed control). Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning.___ 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: Are views active or inactive?
Le 23 déc. 2009 à 12:06, Gregory Weston a écrit : Rick Mann wrote: On Dec 22, 2009, at 19:51:03, Kyle Sluder wrote: On Tue, Dec 22, 2009 at 9:45 PM, Rick Mann rm...@latencyzero.com wrote: I'm listening for that notification. Sure is a clunky way to do things. I've never used a view framework that didn't tell views when they became active/inactive. Views don't become (in)active, windows do. Since there are plenty of things that might be interested in that (Window menu, controllers, views∑), it's done as a notification so all interested parties can listen for it. I'm not against the notification, I just think NSView should have an active property. Views do become inactive (look at any well-designed control). Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. and 'active' is called 'enabled' in Cocoa. -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: storing ivars in core data docs
On Dec 22, 2009, at 21:40, Rainer Standke wrote: is there a way to store regular ivars in docs of a core data doc-based applictions? What's a doc? Seriously, are you talking about a file, or a NSPersistentDocument subclass instance, or what? If you're asking Is it possible to archive arbitrary values as raw binary data or perhaps using the NSKeyedArchiver mechanism in a persistent store alongside but not within the Core Data database? then the answer is no. You have to implement persistent storage for a value kept in a regular ivar as a property of some Core Data entity using the techniques described in the Core Data documentation. ___ 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: storing ivars in core data docs
On 23/12/2009, at 9:18 PM, Quincey Morris wrote: What's a doc? Seriously, are you talking about a file, or a NSPersistentDocument subclass instance, or what? If you're asking Is it possible to archive arbitrary values as raw binary data or perhaps using the NSKeyedArchiver mechanism in a persistent store alongside but not within the Core Data database? then the answer is no. You have to implement persistent storage for a value kept in a regular ivar as a property of some Core Data entity using the techniques described in the Core Data documentation. That's not 100% true, you can store an NSFileWrapper that contains a Core Data store as well as other files, so you can store whatever data you like. See this sample code for an example: http://developer.apple.com/mac/library/samplecode/PersistentDocumentFileWrappers/ It's not perfect but it certainly works. For the OP, as Quincey pointed out, your question is not clear. What are you trying to do? -- Rob Keniger ___ 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: NSObjectController mapped to NSArrayController selection
On Dec 23, 2009, at 00:10, Tom wrote: I have the following situation: NSArrayController which handles array of Core Data objects. Then I want to map it's selection (there can only be one selected at a time) to NSObjectController's contents and then use the object controller for binding to the view. I want to use the object controller as the entry point for the second nib, but I can't get it to work even in the same nib. This is how I figure: NSObjectController bindings (in IB): - Content Object (my NSArrayController) with controller key selection A label: - Value (the NSObjectController) with controller key content and model key name However the label shows nothing no matter what selection is there. NSArrayController's selection is properly updated - if I bind the label to it's selection.name directly it works. What am I missing? Did you try binding the label to controller key selection in the object controller, instead of content? It ought to be the same thing, functionally, but selection is a proxy object so the actual behavior might be slightly different. Did you also check your console log for error messages? It's worth doing so when bindings mysteriously fail to do anything. ___ 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: NSObjectController mapped to NSArrayController selection
Thanks. I did but nothing changed... No message in console also. Just the label always has no selection displayed. I've also verified and the object controller does change it's content/selection properly, so it has probably something to do with the label binding. But I have no clue as to what could be the culprit. Any more ideas? Tomaz 2009/12/23 Quincey Morris quinceymor...@earthlink.net On Dec 23, 2009, at 00:10, Tom wrote: Did you try binding the label to controller key selection in the object controller, instead of content? It ought to be the same thing, functionally, but selection is a proxy object so the actual behavior might be slightly different. Did you also check your console log for error messages? It's worth doing so when bindings mysteriously fail to do anything. ___ 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: Are views active or inactive?
On Dec 23, 2009, at 03:15, Jean-Daniel Dupas wrote: Le 23 déc. 2009 à 12:06, Gregory Weston a écrit : Rick Mann wrote: I'm not against the notification, I just think NSView should have an active property. Views do become inactive (look at any well-designed control). Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. and 'active' is called 'enabled' in Cocoa. Except that it's more complicated than that, not entirely to Cocoa's glory. The first responder in an active window loses what you might call focus when the window becomes inactive. It *also* by default loses the ability to respond to first mouse clicks, except when it doesn't (if the default behavior is overridden). If the view is a control, it may have an enabled-but-inactive appearance (usually, the color is removed or dimmed, such as the selection turning gray, or a NSTableView source list changing from blue to gray) that's different from their disabled appearance (disabled controls don't have selections at all). The appearance may or may not be matched to the first-responder/first-mouse-click state, but that's not consistent behavior nor is it enforced by the frameworks. And, of course, a control may be disabled in an active window for other reasons. And, of course, custom non-control views may choose to represent themselves differently in an inactive window, following the model (well, one of the models) provided by controls, or not. There's no *formal* inactive state for views, although the state is often implemented informally, with greater or lesser consistency depending on the thoroughness of the developer and the state of advancement of the frameworks. (For example, IIRC the ability for a NSTableView to show a either visually inactive state or a disabled state is fairly recent.) So, the answer is still that windows become inactive, but views (formally) do not. What views do (informally) is decided on a case-by-case basis. ___ 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
AuthorizationCreate return code -67049
Hello everyone! In my application I need to execute command with privileges using AuthorizationExecuteWithPrivileges. To obtain authorization reference from system I use the following code const AuthorizationRights* kNoRightsSpecified = NULL; OSStatus err = AuthorizationCreate(kNoRightsSpecified, AuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, authorizationRef); if (err == errAuthorizationSuccess) { NSLog(@Authorization created. Will try to copy rights); copy rights } else { NSLog(@Authorized Failed: error %i , err); } And sometimes get the following error from users: Authorized Failed: error -67049 So, AuthorizationCreate returns -67049 and I can't find this error code in documentation/headers. Does anyone know where to find explanation for this error code? Thanks, Vera Tkachenko___ 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: storing ivars in core data docs
On Dec 23, 2009, at 03:28, Rob Keniger wrote: On 23/12/2009, at 9:18 PM, Quincey Morris wrote: What's a doc? Seriously, are you talking about a file, or a NSPersistentDocument subclass instance, or what? If you're asking Is it possible to archive arbitrary values as raw binary data or perhaps using the NSKeyedArchiver mechanism in a persistent store alongside but not within the Core Data database? then the answer is no. You have to implement persistent storage for a value kept in a regular ivar as a property of some Core Data entity using the techniques described in the Core Data documentation. That's not 100% true, you can store an NSFileWrapper that contains a Core Data store as well as other files, so you can store whatever data you like. See this sample code for an example: http://developer.apple.com/mac/library/samplecode/PersistentDocumentFileWrappers/ It's not perfect but it certainly works. Well, FWIW it was 100% true because I deliberately specified in a persistent store. :) A file wrapper (or, *shudder*, a resource fork) might be a solution for a determined person, but it would be far easier to embed the data in a Core Data property. Assuming that this is what the OP is asking about to begin with. ___ 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: NSObjectController mapped to NSArrayController selection
On Dec 23, 2009, at 03:36, Tom wrote: Thanks. I did but nothing changed... No message in console also. Just the label always has no selection displayed. I've also verified and the object controller does change it's content/selection properly, so it has probably something to do with the label binding. But I have no clue as to what could be the culprit. Any more ideas? I have three answers, to that question. Take your pick: 1. No. 2. You have entered NSController's twilight zone and you should run, run for your life.* 3. If you're intending to use the additional NSObjectController as part of a mechanism for linking 2 nibs, as your original post suggested, I've got a feeling it's not actually going to solve anything, so you might consider doing without it. (Or, in the second nib, binding it to a File's Owner property that's derived from, but isn't, the NSArrayController selection in the first nib.) *I'm omitting my rant about how horrible NSController classes are to use, since I already did it twice this year. ___ 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: Are views active or inactive?
On 23/12/2009, at 10:15 PM, Jean-Daniel Dupas wrote: Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. and 'active' is called 'enabled' in Cocoa. Logically, enabled and active are two separate states - you can have a disabled control in an active window. But, controls typically draw the same way if either of these are false (i.e. the 'disabled' appearance). Views inherit the active state from their windows, so can ask their window for that state any time they need to know. --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: Are views active or inactive?
Le 23 déc. 2009 à 13:50, Graham Cox a écrit : On 23/12/2009, at 10:15 PM, Jean-Daniel Dupas wrote: Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. and 'active' is called 'enabled' in Cocoa. Logically, enabled and active are two separate states - you can have a disabled control in an active window. But, controls typically draw the same way if either of these are false (i.e. the 'disabled' appearance). Views inherit the active state from their windows, so can ask their window for that state any time they need to know. My bad, sorry for the misunderstanding. -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Localization strategies?
Well, Ricky I see you're one of the few who has really thought through all the issues. On 2009 Dec 22, at 19:59, Kyle Sluder wrote: On Tue, Dec 22, 2009 at 11:54 AM, Ricky Sharp rsh...@mac.com wrote: * No plural forms (while allowing plurals can be handled, it's not worth the effort IMO) That's good, because I read somewhere that in some languages, for example Arabic, there are actually different forms for one, two, and three or more. But not using plural forms at all -- I would find that to be very difficult. NSString has support for this with the syntax Blah %1$@ blah %2$@. Bizarrely, it starts at 1, not 0. You're correct Kyle, but I have enough trouble typing %1$@ myself. There it just took me about 10 seconds. When I discovered this feature a few years ago, I decided that either localizers were going to frequently type it wrong, or use some kind of automated typing that would frequently type in the wrong one. So I wrote my own localized string function which does it the way that it was done in Classic Mac OS, with simply %0, %1, %2, and is type-agnostic. That's what I use now, and it seems to be bug-free at this point.___ 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: Virtual Folders in Mac
On 23/12/2009, at 4:39 PM, Akash Nemani wrote: Is there a way to get a virtual folder in mac? Something like the win 7 library folder? Basically I am trying to create a folder in which if a file is copied or dragged, it creates a link to the original file into the folder instead of copying the file. I saw that Burn folder is something similar. But I dont want the burn button in it and would like to create symbolic link instead of alias in the folder since I can access the path of the original file using readlink or stat functions. Not 100% sure, but I think you can achieve this using Folder Actions. This isn't a Cocoa question though, so expect to be upbraided for being off-topic. --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: Localization strategies?
On Tuesday, December 22, 2009, at 09:59PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Tue, Dec 22, 2009 at 11:54 AM, Ricky Sharp rsh...@mac.com wrote: (2) Externalize all strings from the nibs and put them into Localizable.strings. This allows me to have a single file to hand off to translators. I can also group like-items together and fill in nice contextual comments. This shouldn't be necessary; see man ibtool for arguments you can use to generate strings files from your nibs automatically. Been there; done that. The issue with storing strings in nibs is that I cannot place contextual comments anywhere. * No plural forms (while allowing plurals can be handled, it's not worth the effort IMO) Don't cop out with text like One or more items… or There are 5 document(s) open. That looks unprofessional and very un-Mac. No, I'm not doing anything like that. Example: Instead of 10 problems, use Problems: 10. Apple actually makes use of this strategy, thought only for certain languages. For their English localization, they pretty much stick with the plural forms. But, for languages such as Russian, they use the colon approach. I didn't want to have two methods of doing things, so just removed plural forms in their entirety. I've worked with languages with 6 plural forms and it's just not worth the effort. This also leads to a lower translation cost. * No fragmented sentences (i.e. pieces of sentences across multiple UI elements) Is this going to work in Preference panes? If you're already going the multiple-nib route, does doing this really pose a problem? I'm sure you could get this to all work out, but just wanted to keep things simple. -- Rick Sharp Instant Interactive(tm) ___ 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: Localization strategies?
2009/12/23 Jerry Krinock je...@ieee.org: I read somewhere that in some languages, for example Arabic, there are actually different forms for one, two, and three or more. Localizing plurals is hard because the plural rules for different languages are complex. Just stay away from plurals if you can. For the curious reader: https://developer.mozilla.org/en/Localization_and_Plurals /Dado ___ 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
Cocoa bindings and Core Data
Dear List, I am still learning bindings and CoreData, but I have recently completed another relatively basic program using both these technologies. I learn best by seeing other people's code, so in that vein, I'm posting my source (iCredit is the newer program, but Billing Project also uses these basic technologies) in case anyone else might find it helpful. NB: I'm a hack and may have made stylistic or more serious errors, so these should not be treated as though they teach PROPER programming, just adequate programming! Both programs are designed to help small businesses manage different aspects of account maintenance, billing, and debit/credit extensions. They're MIT-license releases, so if you run a small business, feel free to use them within these relatively benign constraints. Happy Programming! -Dan ( http://www.ascendiac.com/macosx.html )___ 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
Questions about UIView from nib
If I have a XIB that I laid out my UI with in IB, and I call that view up as a subview in my main view: NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@Settings owner:self options:nil]; *[self.view addSubview:[nibViews objectAtIndex:0]];* * * *What is the best way to associate a class with the XIB - in IB in the info panel where I can assign a class? * Do I need to import the class into my main view, or by loading up subview the methods are now in that object? Noob questions, I know. ___ 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
Instance method from IB
Apologies for the newbishness of this question, but I've been away from IB for quite some time (and never went very deep with it in the first place). Let's say I want to have two NSButtons (called 1 and 2) that will cause an NSTabView to switch to tab 1 and 2, respectively. I don't want to use the default segmented controller because I'm looking for wide buttons arranged vertically. Simple, right? Just hook the button to selectTabViewItemAtIndex. Hmmmbut selectTabViewItemAtIndex is not an action method so that won't work. Naturally, that makes sense because there's no way for a simple NSButton to know it has to pass something for the index. So some other solutions of which I can think: 1) Subclass the NSButton and have it call selectTabViewItemAtIndex when pressed 2) Subclass the NSButton and have it respond to indexOfSelectedItem as if it were a segmented controller. Then hook the button to takeSelectedTabViewItemFromSender. While this will work, it seems awfully hackish. Having a single button respond to a method clearly intended for a group of items seems wrong. Anything else? What am I missing? It seems like it should be simple in IB alone to say when this button is pressed, show this tab but if there's a way, it's escaping me. Thanks for any input. ___ 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: storing ivars in core data docs
On 12/23/09 4:10 AM, Quincey Morris said: A file wrapper (or, *shudder*, a resource fork) might be a solution for a determined person, but it would be far easier to embed the data in a Core Data property. Yup. But then you have the joy of persistent store migration. :( Another option might be to use the metadata methods, like metadataForPersistentStore:. -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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: Instance method from IB
On 23 dec 2009, at 08.15, Wade Williams wrote: 1) Subclass the NSButton and have it call selectTabViewItemAtIndex when pressed In Cocoa you wouldn't subclass standard controls to implement specific action handling like this. It's not the Cocoa way. I also curious as to why you would even suggest that solution, given that you're asking for a way to do this all in IB. Writing a full subclass to do this would of course involve more code than using the canonical and straight forward solution: action methods. If you're OK with adding a whole new class, why are you not OK with adding a simple action method? 2) Subclass the NSButton and have it respond to indexOfSelectedItem as if it were a segmented controller. Then hook the button to takeSelectedTabViewItemFromSender. While this will work, it seems awfully hackish. Having a single button respond to a method clearly intended for a group of items seems wrong. Indeed. The indexOfSelectedItem is intended to facilitate hooking up to a list control (pop-up button, combo box, form, etc.). Anything else? What am I missing? It seems like it should be simple in IB alone to say when this button is pressed, show this tab but if there's a way, it's escaping me. If you only have two tabs (sounds like you might from the original description) you can hook your buttons up to the -selectNext/PreviousTabViewItem: action methods on the tab view. This might work for you even if you have more than two tabs, depending on what kind of user experience you're looking for. j o a r ___ 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: NSRecursiveLock problems
On Dec 22, 2009, at 6:07 PM, PCWiz wrote: The issue class in my case is NSLayoutManager. I dug through the docs for NSLayoutManager and read the section on thread safety. There were 2 steps to achieving thread safety with NSLayoutManager. First, if the NSLayoutManager belonged to an NSTextView, then the text view must not be displayed while a secondary thread is making changes using its layout manager. The second part was to turn off background layout for the NSLayoutManager. In my case the layout manager was not tied to a text view (I was just using it to get the size of an attributed string) so all I had to do was this: [layoutManager setBackgroundLayoutEnabled:NO]; Those are the two criteria I specified in the release notes as being essential for using NSLayoutManager on a background thread. In general, an NSLayoutManager and associated objects can be used from only a single thread at once, but as long as you have eliminated simultaneous accesses to them from other threads, they should be OK. The tricky part is that view display and background layout will happen automatically on the main thread, so you need to make sure those will not occur for your layout manager while you are using it on a background thread. If you have done that and still see threading issues, please file a bug. 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: Releasing Objects
On Dec 22, 2009, at 11:49 PM, Franck Zoccolo wrote: You said that you're using garbage collection. When using GC retain and release messages do nothing, and the retain count is not used to determine when an objet can be freed from memory. If -retainCount is returning 1, then he can't be using GC. Under GC, -retainCount -- being the utterly useless method that it is that no one should ever call -- returns self. b.bum ___ 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: Releasing Objects
On Dec 22, 2009, at 9:40 pm, Michael Craig wrote: At the point where the tutorial discusses garbage collection (end of ch. 5), I decided to implement the deallocation of the Converter objects created by ConverterController's convert: method. I want the deallocation to happen inside convert:. To test it, I'm using [converter retainCount], thinking that after the object is deallocated, that call will cause an error. This is the wrong way to think about memory management. You shouldn't be thinking in terms of deallocating another object, only in terms of ownership. You want to relinquish ownership of an object when you've finished with it. This is discussed in greater detail in http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/2043 and the memory management rules summarised in http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994. To elaborate on bbum's messages, the documentation for retainCount is quite explicit... http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/retainCount mmalc ___ 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
Objects from XML
I'm looking at converting some C++ code to Objective C. A set of utility classes that I'd written use the expat C library to convert XML into an object graph. As I experimented with switching that over to use NSXMLParser instead, it dawned on me that I was looking at creating a simple-minded, general-purpose XML unmarshaller. Is there something of the kind already freely available? If so, would it be overkill for handling relatively simple XML? ___ 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: Releasing Objects
Michael Craig wrote: If I'm missing some key concept here, just point me in the right direction and I'll go learn it. If it's something more specific, fill me in! In ownership terms, you released the object, so you no longer own it. References to it after that point are illegal, even if the object still exists because it's owned elsewhere. In allocation terms, the instant an object is deallocated, it is no longer a valid object. This does not mean that every reference to it, via its id, will now cause a runtime error. There are practical reasons for doing this, even though it may deviate from a desirable ideal. On the practical level, the memory reclaimed from a deallocated object is not zeroed, filled, marked, or otherwise altered, except as needed by the free-space management code. Freed memory may be reused as other objects are created, so any dangling id from the dead object is no longer an id, but a dangling C pointer: a dangerous thing with unspecified behavior. Your first premise was that an object's retain-count goes to zero, then it's deallocated. In short, you assume there is a brief interval when a valid object has a retain-count of zero, right before it winks out of existence as an object. Logically, however, this is unnecessary. With a retain-count of 1, the release code knows with certainty that the object's memory will be freed, so writing anything to that memory, such as 0 to the retain-count, is unnecessary. If something is unnecessary and executed frequently, it should be eliminated. Your other premise was that a deallocated object will instantly trigger runtime errors when further messaged. That may be an ideal, but it's definitely not how the real runtime works. Better still, what if it's impossible to even have a reference to an invalid object: if you have an id, it exists. That's what GC tries to provide, though it still isn't ideal. -- GG ___ 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: storing ivars in core data docs
Yes, that was my question. Thanks for your help, Rainer On Dec 23, 2009, at 3:18 , Quincey Morris wrote: On Dec 22, 2009, at 21:40, Rainer Standke wrote: is there a way to store regular ivars in docs of a core data doc- based applictions? What's a doc? Seriously, are you talking about a file, or a NSPersistentDocument subclass instance, or what? If you're asking Is it possible to archive arbitrary values as raw binary data or perhaps using the NSKeyedArchiver mechanism in a persistent store alongside but not within the Core Data database? then the answer is no. You have to implement persistent storage for a value kept in a regular ivar as a property of some Core Data entity using the techniques described in the Core Data documentation. ___ 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/lists%40standke.com This email sent to li...@standke.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: Releasing Objects
Thanks! I've got a better grip on memory management now. By the way, I'm working with GC turned off, for the sake of learning this stuff. My bad for not including that. Michael S Craig ___ 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/mkscrg%40gmail.com This email sent to mks...@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: NSRecursiveLock problems
It all seems to be stable now, so turning off background layout worked :-) Thanks Independent Cocoa Developer, Macatomy Software http://macatomy.com On 2009-12-23, at 9:45 AM, Douglas Davidson wrote: On Dec 22, 2009, at 6:07 PM, PCWiz wrote: The issue class in my case is NSLayoutManager. I dug through the docs for NSLayoutManager and read the section on thread safety. There were 2 steps to achieving thread safety with NSLayoutManager. First, if the NSLayoutManager belonged to an NSTextView, then the text view must not be displayed while a secondary thread is making changes using its layout manager. The second part was to turn off background layout for the NSLayoutManager. In my case the layout manager was not tied to a text view (I was just using it to get the size of an attributed string) so all I had to do was this: [layoutManager setBackgroundLayoutEnabled:NO]; Those are the two criteria I specified in the release notes as being essential for using NSLayoutManager on a background thread. In general, an NSLayoutManager and associated objects can be used from only a single thread at once, but as long as you have eliminated simultaneous accesses to them from other threads, they should be OK. The tricky part is that view display and background layout will happen automatically on the main thread, so you need to make sure those will not occur for your layout manager while you are using it on a background thread. If you have done that and still see threading issues, please file a bug. 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: Are views active or inactive?
On Dec 23, 2009, at 03:06:58, Gregory Weston wrote: Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. On the contrary, users can interact with an inactive control. They can't interact with a disabled control. Consider a scroll bar. It can draw in an inactive state (not blue), but you can still interact with it by sending the window scroll events (something I'm unconvinced you should be able to do, but you can, and it proves convenient). In my case, it's a drawing canvas. However, the active drawing tool should not draw when the view is inactive (not frontmost). Since the tool is a singleton object in the app used by many views, it's important to be able to make the distinction. I suppose I could subclass NSControl, but this strikes me as inelegant (and I don't know that it has active/inactive state anyway). -- Rick ___ 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: Are views active or inactive?
On Dec 23, 2009, at 03:15:11, Jean-Daniel Dupas wrote: and 'active' is called 'enabled' in Cocoa. Again, active and enabled are orthogonal properties. -- Rick ___ 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: Objects from XML
On 23 Dec 2009, at 18:01, Phillip Mills wrote: I'm looking at converting some C++ code to Objective C. A set of utility classes that I'd written use the expat C library to convert XML into an object graph. As I experimented with switching that over to use NSXMLParser instead, it dawned on me that I was looking at creating a simple-minded, general-purpose XML unmarshaller. Is there something of the kind already freely available? If so, would it be overkill for handling relatively simple XML? Not really, but depending on what you do with the XML, it might make sense for you to handle it with a custom subclass of NSPersistentStore. ___ 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: Question in regards to a UIView accessing AppDelegate
I have a main view. It calls up a subView (UIView) like so: In the .m of the view controller: #import SettingsView.h //this is my UIView class ... NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@Settings owner: self options:nil]; SettingsView *settingsView = (SettingsView *)[nibViews objectAtIndex:0]; [self.view addSubview:settingsView]; This seems to work. initWithCoder gets called, then drawRect. The xib really only contains a UIImageView with a background image in it. In the SettingsView class I have code that sets up it's UI: .h: #import UIKit/UIKit.h @interface SettingsView : UIView { } @end .m: #import SettingsView.h #import AnalogAppDelegate.h - (void) pickOne:(id)sender { //This doesn't seem to want to work AnalogAppDelegate *appDelegate = (AnalogAppDelegate *)[[UIApplication sharedApplication] delegate]; switch ( [((UISegmentedControl *)sender) selectedSegmentIndex]) { case 0: [appDelegate stopSleep:YES]; //crashes app break; case 1: [appDelegate stopSleep:NO]; //crashes app break; } } - (void)layoutSubviews { UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(120, 300, 80, 30); [btn setTitle:@OK forState:UIControlStateNormal]; [btn addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [self addSubview:btn]; NSArray *itemArray = [NSArray arrayWithObjects: @Enabled, @Disabled, nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(40, 44, 240, 29); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 1; [segmentedControl addTarget:self action:@selector(pickOne:) forControlEvents:UIControlEventValueChanged]; [self addSubview:segmentedControl]; } - (void) aMethod:(id)sender { [self removeFromSuperview]; } In the AnalogAppDelegate I have this simple method: .h: - (void) stopSleep:(BOOL)shouldStop; .m: - (void) stopSleep:(BOOL)shouldStop { NSLog(@stop sleep %@, shouldStop); } I am wondering why the app crashes when I try this. I don't see anything in the debug console, it just dies. -- http://ericd.net Interactive design and development ___ 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: Question in regards to a UIView accessing AppDelegate
Mike. Sent from my iPhone On 23 Dec 2009, at 07:45 PM, Eric E. Dolecki edole...@gmail.com wrote: I have a main view. It calls up a subView (UIView) like so: In the .m of the view controller: #import SettingsView.h //this is my UIView class ... NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@Settings owner: self options:nil]; SettingsView *settingsView = (SettingsView *)[nibViews objectAtIndex: 0]; [self.view addSubview:settingsView]; This seems to work. initWithCoder gets called, then drawRect. The xib really only contains a UIImageView with a background image in it. In the SettingsView class I have code that sets up it's UI: .h: #import UIKit/UIKit.h @interface SettingsView : UIView { } @end .m: #import SettingsView.h #import AnalogAppDelegate.h - (void) pickOne:(id)sender { //This doesn't seem to want to work AnalogAppDelegate *appDelegate = (AnalogAppDelegate *) [[UIApplication sharedApplication] delegate]; switch ( [((UISegmentedControl *)sender) selectedSegmentIndex]) { case 0: [appDelegate stopSleep:YES]; //crashes app break; case 1: [appDelegate stopSleep:NO]; //crashes app break; } } - (void)layoutSubviews { UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(120, 300, 80, 30); [btn setTitle:@OK forState:UIControlStateNormal]; [btn addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [self addSubview:btn]; NSArray *itemArray = [NSArray arrayWithObjects: @Enabled, @Disabled, nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(40, 44, 240, 29); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 1; [segmentedControl addTarget:self action:@selector(pickOne:) forControlEvents:UIControlEventValueChanged]; [self addSubview:segmentedControl]; } - (void) aMethod:(id)sender { [self removeFromSuperview]; } In the AnalogAppDelegate I have this simple method: .h: - (void) stopSleep:(BOOL)shouldStop; .m: - (void) stopSleep:(BOOL)shouldStop { NSLog(@stop sleep %@, shouldStop); } %@ is for objects. You're trying to use it for a BOOL. I am wondering why the app crashes when I try this. I don't see anything in the debug console, it just dies. -- http://ericd.net Interactive design and development ___ 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/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ 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
There must be a better way
In an iPod Touch/iPhone app where the view is in 1 xib and it's controller is in a different one, according to the view-controller-data paradigm, is there a better way to link the view to the controller than [(myView *) [[self view] setController: self] in the controller where controller has been declared id controller; . . . @property (nonatomic, assign) id controller; in myView.h with synthesize controller in myView.m? Charlie Dickman 3tothe...@comcast.net ___ 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 uncheck checkbox in an NSTableView
Good day. I have troubles on unchecking a checkbox in a table view. Here are my codes. Your help is highly appreciated. Im new to cocoa. declarations IBOutlet NSTableView* oTableView; NSMutableArray* oDatas; NSTableColumn *columnInCheckBox; -(IBAction)tableViewSelected:(id) sender; __ -(id) init { self = [super init]; oDatas = [[NSMutableArray alloc] init]; [oDatas addObject:@a]; [oDatas addObject:@b]; [oDatas addObject:@c]; [oDatas addObject:@d]; [oDatas addObject:@e]; [oDatas addObject:@f]; return self; } -(void)awakeFromNib { NSButtonCell *dataCell; dataCell = [[NSButtonCell alloc] init]; [dataCell setButtonType:NSSwitchButton]; [dataCell setTitle:@]; columnInCheckBox = [oTableView tableColumnWithIdentifier:@checkbox]; [columnInCheckBox setDataCell:dataCell]; [dataCell autorelease]; } -(IBAction)tableViewSelected:(id) sender { int row; row = [sender selectedRow]; NSLog(@row selected are:%d,row); } - (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView { return [oDatas count]; } - (id) tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { id returnValue = nil; if([[tableColumn identifier] isEqualToString:@data]) { returnValue = [oDatas objectAtIndex:row]; } else if([[tableColumn identifier] isEqualToString:@checkbox]) { returnValue = [NSNumber numberWithBool:YES]; } return returnValue; } - (void) tableView:(NSTableView *)tableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSButtonCell* buttonCell; if([[tableColumn identifier] isEqualToString:@checkbox]) { buttonCell =[[tableView tableColumnWithIdentifier:@checkbox] dataCellForRow:row]; if([buttonCell state] == 1) { NSLog(@checkbox is check. Need to uncheck 1); NSLog(@current state %d,[buttonCell state]); [buttonCell setState:NSOffState]; [buttonCell setNextState]; NSLog(@new state %d,[buttonCell state]); } else if([buttonCell state] == 0) { NSLog(@checkbox is uncheck. Need to check); NSLog(@current state %d,[buttonCell state]); [buttonCell setState:NSOnState]; [buttonCell setNextState]; NSLog(@new state %d,[buttonCell state]); } } } ___ 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 use (bind) NSArrayController and NSTableView
How to use (bind) NSArrayController and NSTableView in XCode 3.2 In the XCode 3.1 i'm use Referencing Binding in Array Controller Connections ___ 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: Question in regards to a UIView accessing AppDelegate
I JUST discovered that - thanks. THAT caused my EXC_BAD_ACCESS? I spent 2 hours looking and digging and finally NSLogged the app delegate so I knew I had it... and figured it was on the other end. Happy Holidays everyone. I'm too angry at myself to continue for the day. On Wed, Dec 23, 2009 at 3:32 PM, Mike Abdullah cocoa...@mikeabdullah.netwrote: Mike. Sent from my iPhone On 23 Dec 2009, at 07:45 PM, Eric E. Dolecki edole...@gmail.com wrote: I have a main view. It calls up a subView (UIView) like so: In the .m of the view controller: #import SettingsView.h //this is my UIView class ... NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@Settings owner: self options:nil]; SettingsView *settingsView = (SettingsView *)[nibViews objectAtIndex:0]; [self.view addSubview:settingsView]; This seems to work. initWithCoder gets called, then drawRect. The xib really only contains a UIImageView with a background image in it. In the SettingsView class I have code that sets up it's UI: .h: #import UIKit/UIKit.h @interface SettingsView : UIView { } @end .m: #import SettingsView.h #import AnalogAppDelegate.h - (void) pickOne:(id)sender { //This doesn't seem to want to work AnalogAppDelegate *appDelegate = (AnalogAppDelegate *)[[UIApplication sharedApplication] delegate]; switch ( [((UISegmentedControl *)sender) selectedSegmentIndex]) { case 0: [appDelegate stopSleep:YES]; //crashes app break; case 1: [appDelegate stopSleep:NO]; //crashes app break; } } - (void)layoutSubviews { UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(120, 300, 80, 30); [btn setTitle:@OK forState:UIControlStateNormal]; [btn addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [self addSubview:btn]; NSArray *itemArray = [NSArray arrayWithObjects: @Enabled, @Disabled, nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(40, 44, 240, 29); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 1; [segmentedControl addTarget:self action:@selector(pickOne:) forControlEvents:UIControlEventValueChanged]; [self addSubview:segmentedControl]; } - (void) aMethod:(id)sender { [self removeFromSuperview]; } In the AnalogAppDelegate I have this simple method: .h: - (void) stopSleep:(BOOL)shouldStop; .m: - (void) stopSleep:(BOOL)shouldStop { NSLog(@stop sleep %@, shouldStop); } %@ is for objects. You're trying to use it for a BOOL. I am wondering why the app crashes when I try this. I don't see anything in the debug console, it just dies. -- http://ericd.net Interactive design and development ___ 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/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net -- http://ericd.net Interactive design and development ___ 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: Are views active or inactive?
On Dec 23, 2009, at 11:21, Rick Mann wrote: On Dec 23, 2009, at 03:15:11, Jean-Daniel Dupas wrote: and 'active' is called 'enabled' in Cocoa. Again, active and enabled are orthogonal properties. Again, active isn't a *property* of views, or even of controls, for that matter. For *some* Cocoa controls and views, there is an inactive *state* (as you noted, which typically involves suppressing color) that's displayed when the containing window is inactive. Every other representation of an inactive state in a NSView is implemented application by application, view by view, not in the frameworks. In recent Mac OS releases, the HIGs having been moving towards demanding more consistent showing of inactive state in standard controls (and a few standard views). But IIRC your original question was whether there's a standard mechanism that would directly cause a view to redraw itself when its window changed its active state, and answer is still no -- there are only indirect mechanisms (the view must in some sense observe the state of its window). Incidentally, windows don't actually have an active state either. They have key and main states, whose representation is modified by the active state of the application. As I said earlier in this thread, these states are complex, subtle, and to a degree historically jumbled. ___ 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
Window Controllers
In my NSDocument app I have three Panels that will act as inspectors for the document content. In best Cocoa practices, should these Panels be owned by a window controller? db ___ 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 uncheck checkbox in an NSTableView
On Dec 23, 2009, at 02:05, Lance Kwan wrote: I have troubles on unchecking a checkbox in a table view. What troubles? We can't help if we don't know. if([buttonCell state] == 1) Why are you using 0 and 1 for your 'if' tests, instead of NSOffState and NSOnState? { NSLog(@checkbox is check. Need to uncheck 1); NSLog(@current state %d,[buttonCell state]); [buttonCell setState:NSOffState]; [buttonCell setNextState]; This code turns the checkbox off (setState:NSOffState) and then turns it back on again (setNextState). Seems like a bug. NSLog(@new state %d,[buttonCell state]); } ___ 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: There must be a better way
Is there a reason why your view so tightly bound to it's controller? Typically you define a protocol for any object to respond to and expose a delegate property to define that type of interface. Examples of this are very common in AppKit and UIKit, such as NS/UITableView or UIImagePickerController. -- David Duncan @ My iPhone On Dec 23, 2009, at 2:19 PM, Charlie Dickman 3tothe...@comcast.net wrote: In an iPod Touch/iPhone app where the view is in 1 xib and it's controller is in a different one, according to the view-controller- data paradigm, is there a better way to link the view to the controller than [(myView *) [[self view] setController: self] in the controller where controller has been declared id controller; . . . @property (nonatomic, assign) id controller; in myView.h with synthesize controller in myView.m? Charlie Dickman 3tothe...@comcast.net ___ 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/david.duncan%40apple.com This email sent to david.dun...@apple.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: There must be a better way
On Dec 23, 2009, at 11:19 AM, Charlie Dickman wrote: In an iPod Touch/iPhone app where the view is in 1 xib and it's controller is in a different one, according to the view-controller-data paradigm, is there a better way to link the view to the controller than... Surely the controller is File's Owner in the view's xib, so just use an outlet on the view and connect it to the controller. -- Seth Willits ___ 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: Are views active or inactive?
On Dec 23, 2009, at 2:20 PM, Rick Mann wrote: On Dec 23, 2009, at 03:06:58, Gregory Weston wrote: Did you happen to have an 'a-ha' moment when you typed that sentence? Views don't generally have an active/inactive state. Controls, which are a special case of view, do. So have you considered making your custom view an NSControl instead of a simple NSView? That's the thing, you see. Inactive means the user can't interact with it. But the user can't interact with a view that's not a control anyway, so the state has no meaning. On the contrary, users can interact with an inactive control. They can't interact with a disabled control. Consider a scroll bar. It can draw in an inactive state (not blue), but you can still interact with it by sending the window scroll events (something I'm unconvinced you should be able to do, but you can, and it proves convenient). I'd point out that you've kind of gone off your own point here. Quibbling about what it means to interact with a control aside, you're still talking about a *control* having an inactive state, not a (generic) view. In my case, it's a drawing canvas. However, the active drawing tool should not draw when the view is inactive (not frontmost). Since the tool is a singleton object in the app used by many views, it's important to be able to make the distinction. I suppose I could subclass NSControl, but this strikes me as inelegant (and I don't know that it has active/inactive state anyway). With this expanded explanation, I think the correct answer is that you're going about it the wrong way. It's not a normal Mac HI behavior for a drawing canvas to draw itself differently as a side-effect of its window being inactive. ___ 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: Are views active or inactive?
On Dec 23, 2009, at 13:26:11, Gregory Weston wrote: With this expanded explanation, I think the correct answer is that you're going about it the wrong way. It's not a normal Mac HI behavior for a drawing canvas to draw itself differently as a side-effect of its window being inactive. I would disagree. I think it is, and should be formalized in the architecture. That I can check if my view's parent window is the main window just reinforces the need to behave differently when active vs. inactive. It's not elegant, which is why I think the notion should be formalized. -- Rick ___ 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: Localization strategies?
On Dec 23, 2009, at 7:38 AM, Jerry Krinock wrote: Well, Ricky I see you're one of the few who has really thought through all the issues. On 2009 Dec 22, at 19:59, Kyle Sluder wrote: On Tue, Dec 22, 2009 at 11:54 AM, Ricky Sharp rsh...@mac.com wrote: * No plural forms (while allowing plurals can be handled, it's not worth the effort IMO) That's good, because I read somewhere that in some languages, for example Arabic, there are actually different forms for one, two, and three or more. At my day job, we're moving a very large product to Arabic. We definitely didn't want to deal with its 6 plural forms. Official rules can be found here: http://unicode.org/cldr/data/charts/supplemental/language_plural_rules.html But not using plural forms at all -- I would find that to be very difficult. Not as bad as you may think. At my day job, we removed over 3,000 occurrences of plural forms to include (s). Took just three of us about a week. NSString has support for this with the syntax Blah %1$@ blah %2$@. Bizarrely, it starts at 1, not 0. You're correct Kyle, but I have enough trouble typing %1$@ myself. There it just took me about 10 seconds. When I discovered this feature a few years ago, I decided that either localizers were going to frequently type it wrong, or use some kind of automated typing that would frequently type in the wrong one. So I wrote my own localized string function which does it the way that it was done in Classic Mac OS, with simply %0, %1, %2, and is type-agnostic. That's what I use now, and it seems to be bug-free at this point. Yea, ended up writing my own utility as well. ___ 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
Re: Window Controllers
Please disregard my question about Window Controllers. db On Dec 23, 2009, at 1:48 PM, David Blanton wrote: I meant should each Panel have a Window Controller. On Dec 23, 2009, at 1:45 PM, David Blanton wrote: In my NSDocument app I have three Panels that will act as inspectors for the document content. In best Cocoa practices, should these Panels be owned by a window controller? db ___ 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/airedale%40tularosa.net This email sent to aired...@tularosa.net ___ 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
[textView:shouldChangeTextInRanges:replacementStrings:] When does this type of event occur?
What kind of event can trigger a non-linear selection to be replaced by multiple strings in different ranges? ___ 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: [textView:shouldChangeTextInRanges:replacementStrings:] When does this type of event occur?
In many apps, you can hold down the option key to change the cursor into a crosshair, and do a vertical selection. In addition, in apps like Pages, you can hold down the command key to do a non-contiguous selection. I'd imagine that both of these scenarios might result in that method getting invoked. Dave On Dec 23, 2009, at 2:53 PM, Iceberg-Dev wrote: What kind of event can trigger a non-linear selection to be replaced by multiple strings in different ranges? smime.p7s Description: S/MIME cryptographic signature ___ 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: Are views active or inactive?
On 24/12/2009, at 8:26 AM, Gregory Weston wrote: With this expanded explanation, I think the correct answer is that you're going about it the wrong way. It's not a normal Mac HI behavior for a drawing canvas to draw itself differently as a side-effect of its window being inactive. Well, it depends. Drawing canvases may or may not support the idea of a selection, and so highlight selected objects in a certain way. That highlight might want to be sensitive to the active state of the window so that it can be drawn using the inactive control colour when inactive rather than a bright highlight, or turned off altogether. Bright highlighting in inactive windows is distracting and misleading. In DrawKit I do this, and the only way was to subscribe to the window's notifications for becoming/resigning main and refreshing the view. --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: Window Controllers
On 24/12/2009, at 7:45 AM, David Blanton wrote: In best Cocoa practices, should these Panels be owned by a window controller? Yes. --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: Are views active or inactive?
On Dec 23, 2009, at 14:53:43, Graham Cox wrote: On 24/12/2009, at 8:26 AM, Gregory Weston wrote: With this expanded explanation, I think the correct answer is that you're going about it the wrong way. It's not a normal Mac HI behavior for a drawing canvas to draw itself differently as a side-effect of its window being inactive. Well, it depends. Drawing canvases may or may not support the idea of a selection, and so highlight selected objects in a certain way. That highlight might want to be sensitive to the active state of the window so that it can be drawn using the inactive control colour when inactive rather than a bright highlight, or turned off altogether. Bright highlighting in inactive windows is distracting and misleading. In DrawKit I do this, and the only way was to subscribe to the window's notifications for becoming/resigning main and refreshing the view. Thanks for confirming this is the way you do it. Helps reassure me it's a workable solution. Thanks again!___ 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
NSTrackingArea mouse events
I've been going through the NSTrackingArea docs and Apple examples but I can't seem to figure it out. 1. Does NSTrackingArea support mouseDown events? If so, how would I find if the click is within the bounds of a tracking rect in my mouseDown handler? 2. For mouseEntered and mouseExited handlers, how would I find which tracking rect the event occurred in (if there are multiple tracking rects)? Thanks Independent Cocoa Developer, Macatomy Software http://macatomy.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: NSTrackingArea mouse events
On Dec 23, 2009, at 15:03, PCWiz wrote: 1. Does NSTrackingArea support mouseDown events? If so, how would I find if the click is within the bounds of a tracking rect in my mouseDown handler? No. At the time you receive the mouseDown it's assumed you already know which tracking area(s) you're in, since you'll have already received NSMouseEntered events for any tracking areas the mouse has entered. It seems feasible to find the tracking area by hit testing all of them serially, if you don't have the tracking status available and if there aren't a lot of tracking areas. However, that more or less wastes the tracking functionality, so it wouldn't be the preferred approach. 2. For mouseEntered and mouseExited handlers, how would I find which tracking rect the event occurred in (if there are multiple tracking rects)? Use NSEvent's trackingArea property. ___ 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: Window Controllers
I meant should each Panel have a Window Controller. On Dec 23, 2009, at 1:45 PM, David Blanton wrote: In my NSDocument app I have three Panels that will act as inspectors for the document content. In best Cocoa practices, should these Panels be owned by a window controller? db ___ 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/airedale%40tularosa.net This email sent to aired...@tularosa.net ___ 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: NSRecursiveLock problems
Glad to meet you, the DSClickableURLTextField class has been excellent :) I didn't subclass it, I just made my own little modifications to it here and there. Here is the minSizeForContent method: - (NSSize)minSizeForContent { // Grab the height for the text float newHeight = [[self attributedStringValue] heightForWidth:[self frame].size.width]; // Add 10 more pixels onto the size for safety and make new NSSize NSSize newSize = NSMakeSize([self frame].size.width, newHeight + 10.0); return newSize; } The -heightForWidth: method and several other geometrics related methods are being used from a category which can be found here: http://www.sheepsystems.com/sourceCode/sourceStringGeometrics.html The category creates its own NSTextContainer, NSTextStorage, NSLayoutManager, etc. I'm sure it would be more efficient if I used the existing layout manager in DSClickableURLTextField, haven't gotten to that yet. That might be a good feature to add in future versions, a method that performs functions similarly to what is in the category. Other modifications I made (I don't exactly remember), but I changed some things to allow for selection of the text. The issue with this is that now when you click on a link the link text returns to that default blue underline style (haven't found a way around this yet). And sure, I would love to test out the new version :-) Independent Cocoa Developer, Macatomy Software http://macatomy.com On 2009-12-23, at 6:56 PM, Michael Nickerson wrote: On Dec 23, 2009, at 2:08 PM, PCWiz wrote: It all seems to be stable now, so turning off background layout worked :-) Thanks Hey, I know you worked out what is going on, just thought I'd write you directly here. I'm the creator of the DSClickableURLTextField class. Did you subclass it and add in your own stuff for -minSizeForContent? Not that there's anything wrong with that at all (I enjoy seeing the class used!), just thought that I'd chime in and say that you don't really need to create another layout manager for this class. It already creates and uses one for tracking where the URL is when you click it, so you could just use it directly to calculate sizes. And, I actually have an updated version. I'll be posting it to my website sometime soonish, but if you'd like I can send you a copy now. New updated stuff with this version: * Fixes a bug where what the layout manager uses and what the text field shows could be slightly out of sync, * Fixes a bug where centering the text would entirely mess up where it thought the URLs were for clicking, * Now uses -setObjectValue: directly, so it should work with bindings with no extra work, * Adds in tool tips, which show the entire URL (ON by default, but can be turned off), * Adds in dragging of the URL (ON by default, but can be turned off) Also, when you copy (or drag), it now adds the URL to the pasteboard, and will go and find what the text displayed for the URL is and put that in the string pasteboard. Most applications pick up on that and display the text with the link being the URL, though some don't. At the moment there's no way to turn this off - it's one of the things I keep meaning to add in. Let me know if you'd like it, and I'll send it on. -- Darkshadow (aka Michael Nickerson) http://www.nightproductions.net ___ 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 Anomaly?
In my application when I do the following something strange happens. Add a managed object to the store, save the file, then save the file as another name. Upon saving the file with another name, core data will create and then destroy some kind of transitory shadow object of the same kind as the one in the store. Is this normal? --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
Can -[NSTableColumn width] return Not a Number (nan)?
I just spent many hours tracking down a problem that turned out to be that a column width had been written to my app's user defaults as Not a Number (nan). The only line of code that writes this pref assigns it directly from -[NSTableColumn width]. I don't see any indication in the documentation that this method can return nan. Has anyone ever seen -[NSTableColumn width] return nan? Yes, I've fixed the effect by checking it with isnan() on the way in and out of user defaults.___ 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
No delete cursor on drag
draggingSourceOperationMaskForLocal: returns NSDragOperationCopy|NSDragOperationMove|NSDragOperationDelete When my draggingUpdated: returns NSDragOperationCopy, I get the plus cursor When it returns NSDragOperationMove I get the normal arrow cursor ...but when it returns NSDragOperationDelete, I *don't* get the puff of smoke cursor. It should change to that cursor automatically shouldn't it? Any clues about why this would happen? Or do I need to explicitly set it to [NSCursor disappearingItemCursor]? Thanks Gideon ___ 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: Window Controllers
On 24/12/2009, at 7:48 AM, David Blanton wrote: I meant should each Panel have a Window Controller. Yes. --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: Can -[NSTableColumn width] return Not a Number (nan)?
On 24/12/2009, at 2:58 PM, Jerry Krinock wrote: I just spent many hours tracking down a problem that turned out to be that a column width had been written to my app's user defaults as Not a Number (nan). The only line of code that writes this pref assigns it directly from -[NSTableColumn width]. I don't see any indication in the documentation that this method can return nan. Has anyone ever seen -[NSTableColumn width] return nan? I couldn't swear to it, but it could have happened because the width ended up at zero, then something else performed a div-by-zero using that width, and inserted an inf or NaN. I've definitely seen some funny effects if resizing allows certain views, tables among them, to end up with zero widths - re-enlarging rarely works afterwords because in going to zero information about proportions, etc was lost. It's worth checking that no column can go to zero when a window is sized very small - set minimum limits on the window and views as needed to ensure it can't happen. --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 Anomaly?
On Dec 23, 2009, at 7:41 PM, Richard Somers wrote: In my application when I do the following something strange happens. Add a managed object to the store, save the file, then save the file as another name. Upon saving the file with another name, core data will create and then destroy some kind of transitory shadow object of the same kind as the one in the store. Is this normal? Just a wild guess --- are you saving atomically ?When writing NSData objects, as one example, you can write to file atomically, in which case the object is written to a backup file which is renamed if the write succeeds.The idea is that the write either succeeds or fails, but nothing in between that would leave a corrupted file . . . 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
NSCollectionView NSArrayController bindings from outer hell
Hi ! I must have killed the gods of array bindings in a previous life, but I'm pulling my hair (or whatever's left), and, even though I thought I got I, well, I really don't. I'm trying to do something quite simple. I'd like to display a series of images with a label inside an NSCollectionView. Whatever I do, the collectionview remains empty (even though I can see the nice checkered background (since I set up default layout rows/cols) which reflects the size of my customized item view). In a nib file that has a couple windows, the File's Owner is an NSWindowController of mine. Right now, it concentrates most of the controlling. The NSMutableArray which contains the images and strings is a property of the windowController. I created an NSArrayController, bound to the File's Owner, with the model key path to the name of my array (checked spelling etc). I created an NSCollectionView and set it up like this : - content is bound to the arrayController, and controller key is arrangedObjects. - the item prototype is the NSCollectionViewItem that got created automatically. - for the NSCollectionViewItem, its view is the auto-created view that I customized to add an NSImageView and a label. Now, I tried with and without setting the fields in the Attributes inspector. Since the View is inside the same nib as the NSCollectionViewItem, I think I can leave this blank, since the outlet connects them already. - for the view itself (that should be drawn inside the collectionview), the NSTextField (not the cell) is bound to the Collection View Item, and the model key path is set to representedObject._imageUID. (_ImageUID is a property of the content of my NSMutableArray. To make it short, I add simple class instances that have two fields, NSImageView *_image, NSString *_imageUID) - the NSImageView is bound the same way, but to representedObject._image. From what I read all over the net, this should be one way to do it... So, now on to the model side. Maybe my array isn't observed as being updated. I tried a few things... with and without declaring the NSMutableArray as a property, and assigning it through a setter in windowControllerDidLoadNib. I use insertObject: atIndex: to add elements to the array. And I made sure that I add them from the main thread (performOnMainThread or similar calls when necessary). I traced the content of the NSCollectionView from the debugger, and it seems that it doesn't see any of that. But maybe I shouldn't worry about what I see ? The collectionView shows : _content has 0 objects _displayedItems has 0 objects I tried setting the NSCollectionView's content by hand, (with setContent: myArray) but then I get lots of weird warnings : *Could not connect the action orderFrontStandardAboutPanel: to target of class NSCollectionViewItem* *Could not connect the action hide: to target of class NSCollectionViewItem* Could not connect the action terminate: to target of class NSCollectionViewItem *Could not connect the action hideOtherApplications: to target of class NSCollectionViewItem* *Could not connect the action unhideAllApplications: to target of class NSCollectionViewItem* * * And I also tried to send setNeedsDisplay: YES to the collectionView, just in case... So, if anyone has any suggestion, I'd be really glad to hear them. I really don't understand what goes wrong. Somehow, this technology, It simply doesn't work... :) thanks ! ___ 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: NSCollectionView NSArrayController bindings from outer hell
I forgot to mention a couple things : - my NSArrayController has the mode set to Class, and my custom content class setup. - I added a label to the item view that isn't bound to anything, just to see if it would show up, and it doesn't. which really makes me think it's an arraycontroller problem (ie the NSCollectionView remains empty...) ___ 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: NSTableview datasource issues
Greg, Alexander. I finally resolved the issue. I simply deleted and completely rewrote this particular controller as I could not figure out what the problem was. My application is now running without a hitch. Greg, thanks for your proposed approach (by the way the cap was my error, but not the reason for datasource issues). The issue is that reloadData was not launching datasource methods, regardless. Alexander, thanks for your advises about the possible leaks. I will take this into account as I analyze and optimize the entire code before UAT. I appreciate all your help. My concern though: how come Xcode does not flag issues with datasource? What is so strange is that [segmentTableView editColumn:k row:i withEvent:nil select:YES] was launching the datasource methods, whereas reloadData was not. Happy Holidays! -Original Message- From: Greg Guerin [mailto:glgue...@amug.org] Sent: Sunday, December 20, 2009 09:13 PM To: 'list-cocoa-dev' Subject: Re: NSTableview datasource issues I understand your proposition. For some reason, the spaces are stripped off by the e-mail system, but you got it right.Did your email system also capitalize ObjectValueForTableColumn? Actually, segmentDict contains the copy of a global dictionary created by the method [[MyDocument getSectorSegmentData:(id) sender] mutableCopy]. Unfortunately i cannot give here all the code. Also, when I print the datasource and delegate for segmentTableView, it is clear that it is not nil: the log shows SelectorController, which is what it should be. My major puzzle is that all other TableView in the application using different datasources get loaded. Cleaning all targets does not change anything. Brief, the major problem is this: the datasource methods do not get called. Datasource is not nil at run time, no error in the code. The ArrayController is not empty, the code looks fine. I will go back and review for the thousandth time the code from scratch and all the bindings, but up to now, I can't figure out what is wrong.Maybe you can add some assertions in your code. For example, given the way segmentDict is used, it strongly suggests your design is effectively a singleton. That is, there must only be a single instance of SelectorController created and init'ed.The other thing that occurred to me is if an instance of SelectorController is recreated by the nib, and another instance is created in your code, then the instance you see with valid datasource and delegate may not be the instance that the nib is using. One instance may not be getting completely initialized.As a last resort, try stripping classes, xibs, etc. in order to produce a simplified test case that still exhibits the problem. In the process of simplifying, sometimes you do something that causes the problem to go away. Tracking down the change that causes things to work then leads to identifying the cause of the problem. Even if the simplified case still has the problem, you still have something that others can run and help debug. -- GG___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.comHelp/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/cocoa-dev/aronisoft%40afroamerica.netThis email sent to aronis...@afroamerica.net ___ 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: NSCollectionView NSArrayController bindings from outer hell
Here's a followup. I hadn't written the kvo methods for the array inside my windowController (the array which holds the content for the bound NSCollectionView). I did so, and now, as soon as I add an entry to the array I get these strange exceptions : *Could not connect the action orderFrontStandardAboutPanel: to target of class NSCollectionViewItem* *Could not connect the action hide: to target of class NSCollectionViewItem* *Could not connect the action terminate: to target of class NSCollectionViewItem* *Could not connect the action hideOtherApplications: to target of class NSCollectionViewItem* *Could not connect the action unhideAllApplications: to target of class NSCollectionViewItem* * * What I don't understand is that those actions are application or window actions, I can't see why that happens when I add content to the arraycontrolled array ! (it is directly triggered by the insertObject: inMyArrayAtIndex: call). hmmm (getting back to chicken sacrifices, cleaning blood off before it dries out...) *I* *dd* ___ 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: NSCollectionView NSArrayController bindings from outer hell
(Sorry about the many emails) I thought I was using a windowController, actually I handle everything through an NSPersistentDocument that I subclassed. So the File's Owner is an NSPersistentDocument. Could this be the culprit ? ___ 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