Re: Getting a list of all classes, etc...
This worked well (after a little tweaking!) thanks - got the whole caboodle running now. I note that NSObject's superclass is NULL, so I had to switch the order of the while() test in order to correctly detect plain NSObjects (admittedly this will probably never be needed in practice). Here's my implementation (including objective C 2.0 variant), for anyone's further use: @implementation MyRuntimeHelper + (NSArray*)allClassesOfKind:(Class) aClass { // returns a list of all Class objects that return YES to isKindOfClass:aClass currently registered in the runtime NSMutableArray* list = [NSMutableArray array]; Class* buffer = NULL; Class cl; int i, numClasses = objc_getClassList( NULL, 0 ); if( numClasses 0 ) { buffer = malloc( sizeof(Class) * numClasses ); NSAssert( buffer != nil, @couldn't allocate the buffer); (void) objc_getClassList( buffer, numClasses ); for( i = 0; i numClasses; ++i ) { cl = buffer[i]; if( classIsSubclassOfClass( cl, aClass )) [list addObject:cl]; } free( buffer ); } //NSLog(@classes: %@, list); return list; } @end BOOLclassIsNSObject( const Class aClass ) { // returns YES if aClass is an NSObject derivative, otherwise NO. It does this without invoking any methods on the class being tested. return classIsSubclassOfClass( aClass, [NSObject class]); } BOOLclassIsSubclassOfClass( const Class aClass, const Class subclass ) { Class temp = aClass; int match = -1; #ifndef __OBJC2__ while(( 0 != ( match = strncmp( temp-name, subclass-name, strlen( subclass-name ( NULL != temp-super_class )) temp = temp-super_class; #else while(( 0 != ( match = strncmp( class_getName( temp ), class_getName( subclass ), strlen( class_getName( subclass ) ( NULL != class_getSuperclass( temp ))) temp = class_getSuperclass( temp ); #endif return ( match == 0 ); } On 27 Mar 2008, at 4:11 pm, Sherm Pendley wrote: On Thu, Mar 27, 2008 at 12:43 AM, Graham Cox [EMAIL PROTECTED] wrote: I have a class that can contain different objects which all derive from a class R. The container can accept instances of any subclass of R. Each subclass of R implements a CLASS method for a particular feature, returning an array. The container needs to build an array which is the union of all the arrays returned by each subclass. Thus it needs to iterate through a list of all possible subclasses of R, combining the arrays as it goes. Problem is that not all possible subclasses of R are known until runtime, so I need a way to be able to get hold of such a list, based on the fact that they all inherit from R. Note that these are not instances of R, but classes. (I can get a list of instances I have right now, but that doesn't cover the possibility of another object instance derived from R being added after I already built the array). Hope this makes sense - any ideas? You're on the right track, IMHO. What I would do is climb the inheritance tree for each registered class. If you find an ancestor with the name of R, the class you're checking is a subclass. If you get to a root class (i.e. a class whose super_class member is NULL), then it's not. while( NULL != aClass-super_class 0 != strncmp(aClass-name, R, 1) ) aClass = aClass-super_class; BOOL isSubclassOfR = (NULL != aClass-super_class) ? YES : NO; Keep in mind that this is for the ObjC 1 runtime. I haven't yet looked at the ObjC 2 runtime in any detail, so if you're targeting 64-bit Leopard, YMMV. sherm-- ___ 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 [EMAIL PROTECTED]
Re: Core Data/IB questions
On Wed, Mar 26, 2008 at 10:31 PM, Rick Mann [EMAIL PROTECTED] wrote: Question 2: I can see how a text field gets populated when you select an item in the table. How can I get a one table to populate based on the selection in another? Each table should have its own ArrayController if the two tables represent the data from two different entities. Since you entities are related I am assuming one entity has a property that is a to-many relationship to the other entity. Set the ContentSet bindings for ArrayController2 to be the selection of ArrayController1. ArrayController2 ContentSet Bind to = ArrayController1 Controller Key = selection Model Key Path = (the name of the relationship that represents entity2 in entity1) This will cause ArrayController2 to always populate the TableView with the objects selected by ArrayController1 Let me know if that needs to be more clear. Adam ___ 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 [EMAIL PROTECTED]
Re: Writing a preference pane that configures hotkeys?
It doesn't look like NDHotKeyControl implements a setReadyForHotKeyEvent: method. Do I perhaps have an older version of the NDHotKeyControl source code? Surely there is something I'm missing here. I figure I can take your word for it on this, since you wrote the class and all. ;-) - Brian On Wed, 26 Mar 2008 09:56:01 -0400, Nathan Day [EMAIL PROTECTED] wrote: I use those classes myself in a preference pane (Popup Dock) and they work fine. You need to have a NDHotKeyControl to capture the event, you can create an input field in IB and change its class to NDHotKeyControl. You then need to tell the NDHotKeyControl to wait for a HotKey combination event by calling setReadyForHotKeyEvent:, you can alternativly set up a button to send a readyForHotKeyEventChanged: action. On 26/03/2008, at 12:38 AM, Brian Kendall wrote: On Mon, 24 Mar 2008 01:46:27 -0400, Jens Alfke [EMAIL PROTECTED] wrote: Take a look at Nathan Day's NDHotKeyEvent utility code: http://homepage.mac.com/nathan_day/pages/source.xml I tried to use this in my preference pane, but I can't get the control to receive hot key events. There could be something I'm doing wrong when setting up or working with the NDHotKeyControl class, but is there any reason it wouldn't be able to receive events in a preference pane? - Brian ___ 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/nathan_day%40mac.com This email sent to [EMAIL PROTECTED] Nathan Day [EMAIL PROTECTED] http://homepage.mac.com/nathan_day/ ___ 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 [EMAIL PROTECTED]
Key icons?
I'd like to implement something like Xcode's accelerator key- assignment prefs pane. Are there standard icons representing all the special keys on the keyboard? If so, how do I get at them? TIA, -- 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 [EMAIL PROTECTED]
Programmatically invoking Exposé?
Is there any way to programmatically invoke Exposé? TIA, -- 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 [EMAIL PROTECTED]
Re: Key icons?
On 27 Mar 08, at 01:11, Rick Mann wrote: I'd like to implement something like Xcode's accelerator key- assignment prefs pane. Are there standard icons representing all the special keys on the keyboard? If so, how do I get at them? They're all Unicode characters. ⌘ is one of them; the rest are all nearby.___ 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 [EMAIL PROTECTED]
Re: Programmatically invoking Exposé?
Hi Rick, On 2008-03-27, at 18:47, Rick Mann wrote: Is there any way to programmatically invoke Exposé? You could open /Applications/Expose.app, depending on the level of flexibility you need. Jonathon Mah [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: A Tab after 4 SPACEs
On 27.03.2008, at 09:32, Gerriet M. Denkmann wrote: float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)' '].width * 4; I'm pretty new to the text engine myself, but I don't think an NSGlyph can be generated by typecasting a char. Since Monaco or Courier are monospaced, it just so happens that you get the same width as the space would be. But the glyph with number 0x20 is probably a completely different width than the glyph corresponding to a space in other languages. Have you tried asking the glyph storage (I think that's a category that the layout manager adheres to, or maybe it was the text storage) for the correct glyph for the character ' ' ? Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ 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 [EMAIL PROTECTED]
Re: Core Data/IB questions
If I may be so bold, I'd like to jump in on this question. I have a similar situation, but I want to have a table representing a to-many relationship for entity1, which the user can populate by choosing any number of entries from a entity2. e.g. entity2 has 50 entries. entity1 1st entry refers to entries 1, 4, and 9 of entity 2. entity1 2nd entry refers to entries 4, 8 and 26 of entity 2. So I envisage that the table in entity1 should have add and remove buttons. When you click add, a new row is added to the table. The first column in the table is a NSCombobox, which can be used to select from the entries in entity 2. The employee/department tutorial seems to come close to doing this, but as seems to be more the norm, it assumes that all entries in the relationship are wanted, which is not the case here. So, I set up the interface as above (table with NSCombobox, and +/- buttons). I created a special array controller just for this to-many relationship, and bound its contentset to the relevant relationship in entity1. The first column in the table is bound to the specially created array controller, arrangedObjects, but this is a dead end. I can't see how to make the combobox choose the entry. The combo box doesn't have the same binding options as a popup menu. Any advice as to how to approach this would be great. Ian. On 27/03/2008, at 7:34 PM, Adam Gerson wrote: I think that internally when you create a to-many core-data relationship the group of objects is stored as an NSSet as opposed to an array. http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#/ /apple_ref/doc/uid/TP40002147-181724 http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ /apple_ref/doc/uid/20002174-178830-BAJEDEFB On Thu, Mar 27, 2008 at 2:10 AM, Rick Mann [EMAIL PROTECTED] wrote: On Mar 26, 2008, at 11:06 PM, Adam Gerson wrote: Each table should have its own ArrayController if the two tables represent the data from two different entities. Since you entities are related I am assuming one entity has a property that is a to-many relationship to the other entity. Set the ContentSet bindings for ArrayController2 to be the selection of ArrayController1. ArrayController2 ContentSet Bind to = ArrayController1 Controller Key = selection Model Key Path = (the name of the relationship that represents entity2 in entity1) This will cause ArrayController2 to always populate the TableView with the objects selected by ArrayController1 Let me know if that needs to be more clear. Excellent! That was exactly what was missing. Thank you. Why ContentSet, and not ContentArray or one of the other ContentXXX things? -- 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/bianface%40gmail.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Getting a list of all classes, etc...
Actually I did try it this way at one point, and it worked OK with one small kink. It caused the +initialize method of the classes being tested to get called, which for some classes (bearing in mind that it's going through a list of EVERY class in the runtime), triggered some warnings about deprecated classes, for example from NSATSGlyphRenderer (I think it was). The advantage of this way is that it doesn't invoke any methods on the class being tested itself, so works very stealthily ;-) -- S.O.S. On 27 Mar 2008, at 5:59 pm, Chris Suter wrote: On 27/03/2008, at 4:59 PM, Graham Cox wrote: This worked well (after a little tweaking!) thanks - got the whole caboodle running now. I note that NSObject's superclass is NULL, so I had to switch the order of the while() test in order to correctly detect plain NSObjects (admittedly this will probably never be needed in practice). Here's my implementation (including objective C 2.0 variant), for anyone's further use: [snip] You could probably implement classIsSubclassOfClass as: BOOL classIsSubclassOfClass (const Class aClass, const Class subclass) { return class_getClassMethod (aClass, @selector (isSubclassOfClass:)) ? [aClass isSubclassOfClass:subclass] : NO; } - Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Getting other application window reference
Hi, I am developing a Cocoa based application, which will access other application's window and do some resize operations. In Cocoa, is there any way to get other applications(includes non-scriptable ) window references? Thanks, - Apparao. ___ 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 [EMAIL PROTECTED]
Master-Slave Display Exception - Cannot remove an observer
Hello, I sent this just before the Easter break but didn't receive a reply. I thought I'd try again now that we're all back at work. I have what, in WebObjects, we used to call a master-slave display. I show a list of specific Products based on the selected Product Model, hereafter referred to as the 'Model'. So when a user picks a certain Model of sunglasses in the master list, she sees all the different size/color/lens combinations (Products) in the slave list. It works nicely. I use a contentSet binding (programmatically-generated if that makes a difference) to filter the slave list ie. bind it to the to-many relationship from Model to Products. ** In the slave (Product) list, I have a popup that allows the user to change a Product's Model. The popup is usually only used to fix data entry errors - e.g. specifying the wrong Model for a Product. Here is my problem. I noticed that changing the Model results in two exception: NSRangeException -- Cannot remove an observer NSKeyValueObservance 0x30bacf0 for the key path currentCost from Model 0x2a159a0 because it is not registered as an observer. and NSInternalInconsistencyException -- Cannot remove an observer ProductCategorySelectingArrayController 0x10e8650 for the key path model.currentCost from Product 0x1a68130, most likely because the value for the key model has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the Product class. Googling, I found some other developers who have experienced this but no answers were offered. Note that the exceptions are complaining about one of the Model's attributes: currentCost. At other times, the exception complains about another attribute: 'active' -- its unclear whether that refers to the Model's 'active' attribute or the Product's 'active' attribute. Should I be reporting a bug? Thanks, Steve ** this likely has little to do with my question, but for the curious: I programmatically bind a contentSet based on the setting of a radio button with two choices: 'All' and Model. All means show all products, Model means show just the Products for the selected Model. I only have the problem in Model mode. ___ 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 [EMAIL PROTECTED]
Re: Ephemeral Changes
Am 27.03.2008 um 11:57 schrieb Gerriet M. Denkmann: On 26 Mar 2008, at 22:56, Graham Cox wrote: The undo manager will directly change the data in the text view using an invocation or target/action - it doesn't go back through changeFont: normally, which is really a high level method. Maybe the solution to this is to subclass NSUndoManager so that you can hook into the undo and redo methods and use those opportunities to modify the change count of the document. So I implement in MyUndoManager: - (void)undo { NSString *action = [self undoActionName]; [ super undo ]; if ( action contains Font ) [myDocument updateChangeCount:NSChangeUndone]; } Maybe there's a way to trigger on the action selector instead of the action name? However, even the action selector _might_ change in future AppKit versions, so even this would be a somewhat fragile solution. I'd still think that it might be easier to register you own undo action for the font changes instead of trying to hijack the automatic undo... just my €.02, /jum ___ 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 [EMAIL PROTECTED]
Re: to include a C++ class in proj
Am 27.03.2008 um 14:44 schrieb Nick Rogers: are we allowed to do that in a cocoa proj. if so how do we declare the class. Is it like? class MyClass { } this is throwing error at the first line: parse error before 'MyClass' token what headers do i need to include for a C++ class? Make sure your source file is compiled as Objective-C++. The easiest way is to give the file a '.mm' extension. Alternatively, you can change the file type in the inspector panel for the source file, but I prefer to indicate the language by file extension - it saves me a lot of headaches why things work different than expected ;-) Also, your declaration above is missing a trailing semicolon - I guess that's not the issue here, but I have seen strange apparently out-of- location error messages when gcc gets confused due to missing semicolons... HTH, /jum ___ 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 [EMAIL PROTECTED]
Re: to include a C++ class in proj
On Thu, Mar 27, 2008 at 9:44 AM, Nick Rogers [EMAIL PROTECTED] wrote: are we allowed to do that in a cocoa proj. if so how do we declare the class. Is it like? class MyClass { } this is throwing error at the first line: parse error before 'MyClass' token To compile a file as Objective-C++, you need to give it a .mm extension instead of .m. See also: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_12_section_3.html sherm-- ___ 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 [EMAIL PROTECTED]
Re: to include a C++ class in proj
On Mar 27, 2008, at 7:05 AM, Nick Rogers wrote: hi, the semicolon is there. i've changed extension to .hh and .mm, still the same error. What file did you change to .mm, the header or the source file? Remember, header files are not compiled (well, generally not), they are included in implementation files by the preprocessor, then that gets compiled. The file(s) that include your header must be compiled as C++ or Objective-C++. Try changing the extension of the source file(s) that include your class to .mm. There is no need to call the header file .hh. --Brady ___ 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 [EMAIL PROTECTED]
Re: applicationWillTerminate and animations
On Thu, Mar 27, 2008 at 10:14 AM, Mitchell Livingston [EMAIL PROTECTED] wrote: Hello, When my program quits, I would like to fade out all the windows using the animator. When I put this code in the applicationWillTerminate: method, however, it appears to be called but doesn't animate. How would I got about to get this to work? I'd try putting it in applicationShouldTerminate:, and return NSTerminateLater to give the app time to run the fade-out animation. Then, when the animation completes, you can call [NSApp replyToApplicationShouldTerminate:YES]. sherm-- ___ 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 [EMAIL PROTECTED]
Re: Leopard on PPC
On Wed, Mar 26, 2008 at 4:48 PM, Sherm Pendley [EMAIL PROTECTED] wrote: On Wed, Mar 26, 2008 at 7:04 PM, Lorenzo [EMAIL PROTECTED] wrote: Hi Laurent, I am going to debug and let you know. Right now I have found these lines. Might they cause the trouble on Leopard PPC? number = CFNumberCreate(NULL, kCFNumberFloatType, destSize.width); options = [NSDictionary dictionaryWithObjectsAndKeys: (id) kCFBooleanTrue, (id) kCGImageSourceShouldCache, (id) kCFBooleanTrue, (id) kCGImageSourceCreateThumbnailFromImageIfAbsent, (id) number, (id) kCGImageSourceThumbnailMaxPixelSize, NULL]; options = [NSDictionary dictionaryWithObjectsAndKeys: (id) kCFBooleanTrue,(id) kCGImageSourceShouldCache, (id) kCFBooleanTrue,(id) kCGImageSourceShouldAllowFloat, NULL]; I'm deeply suspicious of those typecast CFBoolRefs. Not every Core Foundation class is toll-free bridged. CFNumber is, but I don't see any indication in the CF reference that CFBoolean is. Have you tried using NSNumber objects instead of those kCFBooleanTrue constants? CFBoolean *is* toll free bridged to NSNumber. -- Clark S. Cox III [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Leopard on PPC
On Wed, Mar 26, 2008 at 4:04 PM, Lorenzo [EMAIL PROTECTED] wrote: Hi Laurent, I am going to debug and let you know. Right now I have found these lines. Might they cause the trouble on Leopard PPC? No, but this line will cause problems when/if you build for 64-bit: number = CFNumberCreate(NULL, kCFNumberFloatType, destSize.width); Use kCFNumberCGFloatType instead of kCFNumberFloatType, and make sure that you later CFRelease(number). Or just use NSNumber. options = [NSDictionary dictionaryWithObjectsAndKeys: (id) kCFBooleanTrue, (id) kCGImageSourceShouldCache, (id) kCFBooleanTrue, (id) kCGImageSourceCreateThumbnailFromImageIfAbsent, (id) number, (id) kCGImageSourceThumbnailMaxPixelSize, NULL]; options = [NSDictionary dictionaryWithObjectsAndKeys: (id) kCFBooleanTrue,(id) kCGImageSourceShouldCache, (id) kCFBooleanTrue,(id) kCGImageSourceShouldAllowFloat, NULL]; Also, be sure that you are not releasing either of the options dictionary, as they are already autoreleased for you. -- Clark S. Cox III [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: A Tab after 4 SPACEs
On 27.03.2008, at 10:08, Uli Kusterer wrote: But the glyph with number 0x20 is probably a completely different width than the glyph corresponding to a space in other languages. I meant in other *fonts*, not languages. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ 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 [EMAIL PROTECTED]
Re: Core Data/IB questions
Is what you are describing similar to the To Dos example at: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html Adam On Thu, Mar 27, 2008 at 5:33 AM, Ian Jackson [EMAIL PROTECTED] wrote: If I may be so bold, I'd like to jump in on this question. I have a similar situation, but I want to have a table representing a to-many relationship for entity1, which the user can populate by choosing any number of entries from a entity2. e.g. entity2 has 50 entries. entity1 1st entry refers to entries 1, 4, and 9 of entity 2. entity1 2nd entry refers to entries 4, 8 and 26 of entity 2. So I envisage that the table in entity1 should have add and remove buttons. When you click add, a new row is added to the table. The first column in the table is a NSCombobox, which can be used to select from the entries in entity 2. The employee/department tutorial seems to come close to doing this, but as seems to be more the norm, it assumes that all entries in the relationship are wanted, which is not the case here. So, I set up the interface as above (table with NSCombobox, and +/- buttons). I created a special array controller just for this to-many relationship, and bound its contentset to the relevant relationship in entity1. The first column in the table is bound to the specially created array controller, arrangedObjects, but this is a dead end. I can't see how to make the combobox choose the entry. The combo box doesn't have the same binding options as a popup menu. Any advice as to how to approach this would be great. Ian. On 27/03/2008, at 7:34 PM, Adam Gerson wrote: I think that internally when you create a to-many core-data relationship the group of objects is stored as an NSSet as opposed to an array. http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#/ /apple_ref/doc/uid/TP40002147-181724 http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ /apple_ref/doc/uid/20002174-178830-BAJEDEFB On Thu, Mar 27, 2008 at 2:10 AM, Rick Mann [EMAIL PROTECTED] wrote: On Mar 26, 2008, at 11:06 PM, Adam Gerson wrote: Each table should have its own ArrayController if the two tables represent the data from two different entities. Since you entities are related I am assuming one entity has a property that is a to-many relationship to the other entity. Set the ContentSet bindings for ArrayController2 to be the selection of ArrayController1. ArrayController2 ContentSet Bind to = ArrayController1 Controller Key = selection Model Key Path = (the name of the relationship that represents entity2 in entity1) This will cause ArrayController2 to always populate the TableView with the objects selected by ArrayController1 Let me know if that needs to be more clear. Excellent! That was exactly what was missing. Thank you. Why ContentSet, and not ContentArray or one of the other ContentXXX things? -- 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/bianface%40gmail.com This email sent to [EMAIL PROTECTED] ___ 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/agersonl%40gmail.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Leopard on PPC
OK, so where is that documented then? As I said, the CFBoolean reference says not a word about it: http://developer.apple.com/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html By contrast, every other toll-free bridged CF class I can think of explicitly documents that fact. This blog post has more info on the subject: http://belkadan.com/blog/2008/01/NSNumber-CFNumber-and-CFBoolean/ Matt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Leopard on PPC
On Mar 27, 2008, at 10:59 AM, Sherm Pendley wrote: CFBoolean *is* toll free bridged to NSNumber. OK, so where is that documented then? As I said, the CFBoolean reference says not a word about it: It's more subtle than that. CFNumber is toll-free bridged with NSNumber. toll-free bridged things need to work both ways - where you can use one, you can use the other. If CFBoolean were toll-free bridged with NSNumber then you can use an NSNumber where you can use a CFBoolean. But since you can also use a CFNumber where you can use an NSNumber, this would mean that you can use a CFNumber where there is a CFBoolean, which you can't. CFBoolean is instead just partially bridged. You can use kCFBooleanTrue wherever you can use [NSNumber numberWithBool: YES] and kCFBooleanFalse wherever you can use [NSNumber numberWithBool: NO] (in that CFBoolean has enough scaffolding to support NSNumber routines, and CFBooleanGetValue understands NSNumber). This does not imply that [NSNumber numberWithBool: YES] == kCFBooleanTrue (it may be, but that's not documented as such), just that they are interchangeable. For example, from http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#//apple_ref/doc/uid/20001010-BBCBDBJE Cocoa property lists organize data into named values and lists of values using these classes: •NSArray •NSDictionary •NSData •NSString (java.lang.String in Java) •NSNumber (subclasses of java.lang.Number in Java) •NSDate The Core Foundation property list API, defined in CoreServices/ CoreServices.h, supports the following Core Foundation types: •CFArray •CFDictionary •CFData •CFString •CFDate •CFNumber •CFBoolean Because all these types can be automatically cast to and from their corresponding Cocoa types, you can use the Core Foundation property list API with Cocoa objects. In most cases, however, methods provided by theNSPropertyListSerialization class should provide enough flexibility. So it is documented that they can be automatically cast to and from their corresponding Cocoa types (assuming you're willing to grant that NSNumber is the corresponding type for CFBoolean, but they do say _all_ of the types, and if it's not NSNumber, there's no clear other candidate). Glenn Andreas [EMAIL PROTECTED] http://www.gandreas.com/ wicked fun! quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art ___ 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 [EMAIL PROTECTED]
NSScroller question
Hi, NSScroller has a small view, by default two pixels high, just above the scroller and below the NSTableHeaderView's corner view. How can I get at this view? If you look at the XCode interface you can see they have put an icon in this view (the one that splits the editor view) and made it larger. I would like to remove the view completely so the scroller goes all the way up to the edge of the corner view. This question has been addressed before in the archives, but unfortunately the link pointing to an answer is no longer valid. Thanks. F. ___ 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 [EMAIL PROTECTED]
Re: NSMapTable with pointer keys ?
[NSMapTable mapTableWithKeyOptions:NSMapTableObjectPointerPersonality valueOptions:NSMapTableStrongMemory] (reading the doc for NSMap, I figured these are the right options) However, when trying to fetch an object with a void* key to check for its presence (using the C api as recommended) NSMapGet(myMap, aKey); I get an instant crash and looking at the stack trace, it's because aKey is being sent an ObjC message, to which it will hard time replying since it's not an NSObject in the first place. That’s because you’ve marked the keys as being object pointers; you’ve got your key and value pointer functions reversed. (Also be sure you want the StrongMemory personality, and not OpaqueMemory.) -Ben___ 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 [EMAIL PROTECTED]
Re: Ephemeral Changes
On 27 Mar 2008, at 14:46, Jens Miltner wrote: Am 27.03.2008 um 11:57 schrieb Gerriet M. Denkmann: On 26 Mar 2008, at 22:56, Graham Cox wrote: The undo manager will directly change the data in the text view using an invocation or target/action - it doesn't go back through changeFont: normally, which is really a high level method. Maybe the solution to this is to subclass NSUndoManager so that you can hook into the undo and redo methods and use those opportunities to modify the change count of the document. So I implement in MyUndoManager: - (void)undo { NSString *action = [self undoActionName]; [ super undo ]; if ( action contains Font ) [myDocument updateChangeCount:NSChangeUndone]; } Maybe there's a way to trigger on the action selector instead of the action name? However, even the action selector _might_ change in future AppKit versions, so even this would be a somewhat fragile solution. I'd still think that it might be easier to register you own undo action for the font changes instead of trying to hijack the automatic undo... just my €.02, /jum You are right. And I have just implemented your suggestions. And all seems to be perfect now. Thank you again! Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSToolbar doesn't add default items issue on 10.5.2
I've got some NSToolbar code, which seems to have suddenly stopped working on Leopard only. - (void) setupToolbar { NSLog(@Setting up toolbar); //[self removeObsoleteToolbarIdentifiers]; NSToolbar *toolbar = [[MMICleanerToolbar alloc] initWithIdentifier:@CleanerToolbar]; [toolbar setAllowsUserCustomization:YES]; [toolbar setAutosavesConfiguration:YES]; [toolbar setDelegate:self]; NSLog(@Setting toolbar %@ for window %@, toolbar, mMainCleanerWindow); [mMainCleanerWindow setToolbar:toolbar]; // release it as well? TODO NSLog(@Set up toolbar); } MMICleanerToolbar is a subclass of NSToolbar, but actually doesn't implement any methods, so it's an NSToolbar for all intents and purposes. On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers: method get called, followed by the NSToolbarItem calls, after the setToolbar: method. On Leopard (10.5.2/9C31) [latest security update not installed yet], the delegate methods aren't getting called, and I get an empty toolbar, which looks to be slightly less tall than the standard toolbar with small items. I rolled back over a few revisions of my app, and they all seem to be affected, so it doesn't seem like I've broken anything recently. The first user report I got for this was today (in fact I got two). As I workaround, I'm checking [[toolbar items] count], after setToolbar: and manually inserting the default item set if the toolbar is 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 [EMAIL PROTECTED]
NSTextField and IB Weirdness
I am using Xcode 2.5 and IB Version 2.5.6 (489). I have a window with two NSTextFields. Both are static. I've verified all my outlets and connections are valid. Both outlet types are set to NSTextField in IB's inspector pallette. However, when I generate the class files, no matter what I do, the first NSTextField is created as type id instead of NSTextField. When my object initializes in awakeFromNib, the debugger shows outlet listed as a NSTextField initialized, but the one created as id is nil. Even if I change the id outlet's type to NSTextField, it still will not initialize. I then go back to IB and verify that my item in the window is still set to type NSTextField, but it won't initialize no matter what I do. Both NSTextField's are identical. One works, one doesn't and it isn't clear why. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: outlineViewSelectionDidChange not called
On Thu, Mar 27, 2008 at 5:17 PM, Adam Gerson [EMAIL PROTECTED] wrote: Ok, I understand. So I bind both the OutlineView and the TreeController to a third object that keeps them both in sync to the same SelectionIndexPath value. No -- you bind the view to the controller and the controller to the model. However, when I tried this my OutlineView was blank. I think the Outline Views's selectionIndexPaths binding refers to the selectionIndexPaths of its content provider (in this case the tree controller). I dont think and outline view has selectionIndexPaths properties of its own. If your outline view is blank there is a problem with your content/value bindings; this is a separate issue to the selection index path bindings. Basically, you need the following bindings (assuming you have NSMutableArray properties called content and selectionIndexPaths in your File's Owner): (View to Controller bindings:) NSOutlineView's Content to NSTreeController's arrangedObjects. NSOutlineView's Selection Index Paths to NSTreeController's selectionIndexPaths NSTableColumn's Value to NSTreeController's arrangedObjects.nodeName (Controller to Model bindings:) NSTreeController's Content Array to File's Owner's content NSTreeController's Selection Index Paths to File's Owner's selectionIndexPaths Then, if you need to update some non controller bound GUI controls when the selection changes, you need your secondary controller (well, it's neither model nor view, is it?!) to observe your File's Owner's selectionIndexPaths (using addObserver:forKeyPath:options:context:) and update the controls accordingly. Best wishes, Hamish ___ 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 [EMAIL PROTECTED]
Re: NSToolbar doesn't add default items issue on 10.5.2
On Mar 27, 2008, at 10:58 AM, Martin Redington wrote: On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers: method get called, followed by the NSToolbarItem calls, after the setToolbar: method. On Leopard (10.5.2/9C31) [latest security update not installed yet], the delegate methods aren't getting called, and I get an empty toolbar, which looks to be slightly less tall than the standard toolbar with small items. Hmm. When you open up your app's preferences with Property List Editor, what data is there for your toolbar, as its autosaved configuration? -Peter ___ 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 [EMAIL PROTECTED]
Core Data IB in prefs pane
I'm trying to use what I learned yesterday about Core Data in a System Prefs pane. I created an Entity data model, and then tried to add an NSTable and some buttons and wire them up the same way I'd seen the Core Data Entity tool do it in IB. But, it didn't work. So I tried using the Core Data Entity tool to let IB do it, and it disables the Add and Remove buttons. The only difference I can spot is in yesterday's project, the File's Owner is an NSDocument. Today, it's a PrefsPane. Is it possible to use this stuff in a prefs pane? What am I missing? Thanks! -- 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 [EMAIL PROTECTED]
programatically show NSSegmentedCell menu?
I'm trying to programatically show a NSSgetmentedCell menu, as if the user has clicked on that segmented cell. For normal popup buttons you can do this with 'performClick:', but that doesn't work for segmented controls, because it will always just perform the click on the middle cell. Is there a way to do a targeted performClick on a NSSegmentedControl? That's targeted to a specific cell? Thanks, Jesse ___ 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 [EMAIL PROTECTED]
Re: Interface Builder
Well, I tried some things at home but didn't get success. =( I'm trying to do this: I have a controller with an array of accounts. And these albums has a type associated to it. For example: ACCOUNT 01 - BANK ACCOUNT ACCOUNT 02 - BANK ACCOUNT ACCOUNT 03 - LOAN ACCOUNT ACCOUNT 04 - BANK ACCOUNT I want to show, as in iPhoto hierararchy, this way: BANK ACCOUNT ACCOUNT 01 ACCOUNT 02 ACCOUNT 04 LOAN ACCOUNT ACCOUNT 03 When the user clicks in any account, in the main view it shows its details. And you can hide/show sub-items by clicking on the parent (in this example, bank account or loan account). I tried to find any source code as an example, but I could not find any. =( Can anyone help me?! Please?! Thanks! On 3/17/08, Thiago Rossi [EMAIL PROTECTED] wrote: thanks for your help, robert. you helped me a lot! =) On Mon, Mar 17, 2008 at 7:43 PM, Robert Walker [EMAIL PROTECTED] wrote: Most of what you see in this window is likely a custom view designed and built by the Apple iPhoto developers. The blue sidebar is one pane of a split view with what's probably a customized tree view. The photo area window can now be accomplished using the new image browser from the image kit. The toolbar at the bottom of the window is likely a custom view. On Mar 16, 2008, at 10:57 AM, Thiago Rossi wrote: I would like to know how to draw a window like iPhoto. For example, what kind of object are the light-blue bar on the left? And the dark one (main)? And the toolbar inside the dark one, on the bottom? Ok, they may be easy. But how about the object that display the text LIBRARY? And the other one for RECENT? And Events, Photos, Last 12 Months, Last Import, Flagged, Trash, albums…? Could you please help me? Picture 1.png ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([EMAIL PROTECTED]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/robert.walker%40bennettig.com This email sent to [EMAIL PROTECTED] Robert Walker [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: programatically show NSSegmentedCell menu?
On Mar 27, 2008, at 1:21 PM, Jesse Grosjean wrote: I'm trying to programatically show a NSSgetmentedCell menu, as if the user has clicked on that segmented cell. For normal popup buttons you can do this with 'performClick:', but that doesn't work for segmented controls, because it will always just perform the click on the middle cell. Is there a way to do a targeted performClick on a NSSegmentedControl? That's targeted to a specific cell? Hi Jesse. Use setSelectedSegment instead. NSSegmentedControl* seg; ... [seg setSelectedSegment:4]; -- Bob Clark Lead Software Development Engineer RealPlayer Mac/Unix RealNetworks, Inc. ___ 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 [EMAIL PROTECTED]
Re: Leopard on PPC
On Mar 27, 2008, at 10:29 AM, Clark Cox wrote: On Wed, Mar 26, 2008 at 4:04 PM, Lorenzo [EMAIL PROTECTED] wrote: Hi Laurent, I am going to debug and let you know. Right now I have found these lines. Might they cause the trouble on Leopard PPC? No, but this line will cause problems when/if you build for 64-bit: number = CFNumberCreate(NULL, kCFNumberFloatType, destSize.width); Use kCFNumberCGFloatType instead of kCFNumberFloatType, and make sure that you later CFRelease(number). Or just use NSNumber. You could just use NSNumber, if it were not for the fact that NSNumber doesn't have any API support for CGFloat. :-) (rdar: //5812091) You can add it with a category: @implementation NSNumber (CGFloatSupport) + (NSNumber *) numberWithCGFloat: (CGFloat) cgFloatValue { CFNumberRef cfVersion = CFNumberCreate(NULL, kCFNumberCGFloatType, cgFloatValue); return [NSMakeCollectable(cfVersion) autorelease]; } - (CGFloat) cgFloatValue { CGFloat retVal = 0; CFNumberGetValue((CFNumberRef) self, kCFNumberCGFloatType, retVal); return retVal; } @end ___ 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 [EMAIL PROTECTED]
Static in Subclasses
I need to create a series of classes that implement the Singleton design pattern. These classes have a lot of similar methods (I am trying to create a series of DAOs see: http://en.wikipedia.org/wiki/Data_Access_Object) . I was thinking that it would be best to create a super class, and a series of subclasses to that super class. The problem I am running upon is that the Singleton pattern requires a static variable. How can I get a variable that is static to each subclass, but that is declared in the super class? for example I tried this. /*- #import Cocoa/Cocoa.h @interface SuperClass : NSObject { } - (void) addToMyVar; - (int) getMyVar; @end @implementation SuperClass static int MyVar = 0; - (void) addToMyVar { ++MyVar; } - (int) getMyVar { return MyVar; } @end @interface SubClass1 : SuperClass { } @end @implementation SubClass1 @end @interface SubClass2 : SuperClass { } @end @implementation SubClass2 @end int main(int argc, char *argv[]) { SubClass1 *mySubClass1 = [[SubClass1 alloc] init]; SubClass2 *mySubClass2 = [[SubClass2 alloc] init]; NSLog(@1 before = %i, [mySubClass1 getMyVar]); NSLog(@2 before = %i, [mySubClass2 getMyVar]); [mySubClass1 addToMyVar]; NSLog(@1 after 1 = %i, [mySubClass1 getMyVar]); NSLog(@2 after 1 = %i, [mySubClass2 getMyVar]); [mySubClass2 addToMyVar]; NSLog(@1 after 2 = %i, [mySubClass1 getMyVar]); NSLog(@2 after 2 = %i, [mySubClass2 getMyVar]); return NSApplicationMain(argc, (const char **) argv); } --*/ which outputs the following 2008-03-27 14:34:31.040 TimeKeeper[790:10b] 1 before = 0 2008-03-27 14:34:31.045 TimeKeeper[790:10b] 2 before = 0 2008-03-27 14:34:31.046 TimeKeeper[790:10b] 1 after 1 = 1 2008-03-27 14:34:31.047 TimeKeeper[790:10b] 2 after 1 = 1 2008-03-27 14:34:31.048 TimeKeeper[790:10b] 1 after 2 = 2 2008-03-27 14:34:31.049 TimeKeeper[790:10b] 2 after 2 = 2 I want it so that it outputs 2008-03-27 14:34:31.040 TimeKeeper[790:10b] 1 before = 0 2008-03-27 14:34:31.045 TimeKeeper[790:10b] 2 before = 0 2008-03-27 14:34:31.046 TimeKeeper[790:10b] 1 after 1 = 1 2008-03-27 14:34:31.047 TimeKeeper[790:10b] 2 after 1 = 0 2008-03-27 14:34:31.048 TimeKeeper[790:10b] 1 after 2 = 1 2008-03-27 14:34:31.049 TimeKeeper[790:10b] 2 after 2 = 1 Thank you, Justin Giboney ___ 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 [EMAIL PROTECTED]
Re: NSScroller question
On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote: Hi, NSScroller has a small view, by default two pixels high, just above the scroller and below the NSTableHeaderView's corner view. How can I get at this view? If you look at the XCode interface you can see they have put an icon in this view (the one that splits the editor view) and made it larger. I would like to remove the view completely so the scroller goes all the way up to the edge of the corner view. This question has been addressed before in the archives, but unfortunately the link pointing to an answer is no longer valid. Thanks. F. See NSTableView.h: /* Get and set the cornerView. The cornerView is the view that appears directly to the right of the headerView above the vertical NSScroller. The scroller must be present for the cornerView to be shown. Calling - setCornerView: may have the side effect of tiling the enclosingScrollView to accomodate the size change. The default value is an internal class that properly fills in the corner. */ - (void)setCornerView:(NSView *)cornerView; - (NSView *)cornerView; -- Troy Stephens Cocoa Frameworks Apple, Inc. ___ 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 [EMAIL PROTECTED]
Re: CoreAnimation weird problems with NSView animator
On Mar 26, 2008, at 9:12 AM, Milen Dzhumerov wrote: Hi all, I've been playing with CA today and encountered some weird problems. Firstly, I tested setHidden: on an animator on a NSSegmentedView and it worked fine - it gets faded in/out. Now, all the problems I encountered happen in another NIB file. I've got the following piece of code (in a controller): [self.generalView setHidden:YES]; [self.window setContentView:self.generalView]; [[self.generalView animator] setHidden:NO]; This should produce a fade transition, as long as self.generalView's superview, or an ancestor view higher up, has wantsLayer == YES. Does it help if you wrap the un-hide in an explicit NSAnimationContext begin/end? [NSAnimationContext beginGrouping]; [[self.generalView animator] setHidden:NO]; [NSAnimationContext endGrouping]; I expect this to animate the view but it doesn't happen - no animation goes on. I've made sure that all NSView's want layers. I also noticed some other unusual problems with the said NIB: - Animations work on a random basis (CA animations) A more specific example would help. - If I attach an outlet to a particular NSPopUpButton, it disappears. Removing the outlet makes it appear again The NSPopUpButton disappears? What do you see when you look at the popup button's state when this has happened? (i.e. What does - isHiddenOrHasHiddenAncestor report, and frame, superview, etc.?) Something must be collapsing it, hiding it, removing it from the view tree, or moving it out of its superview's visibleRect. I think I'm missing some setup here but I cannot figure out exactly what it is. The NIB (saved as a XIB) was created from scratch (i.e., not included in a project template) but I can't see how this can be a problem. Any help is greatly appreciated. M -- Troy Stephens Cocoa Frameworks Apple, Inc. ___ 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 [EMAIL PROTECTED]
Re: Static in Subclasses
On Thu, Mar 27, 2008 at 8:44 PM, Justin Giboney [EMAIL PROTECTED] wrote: How can I get a variable that is static to each subclass, but that is declared in the super class? In short, you can't. static in C means within the scope of the source file. Split your subclasses off into their own files, define your static variables there, give them accessor methods, and use those accessors in the superclass. Hamish ___ 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 [EMAIL PROTECTED]
Re: How to get current renderer for an NSOpenGLView?
On Mar 26, 2008, at 2:54 PM, Duncan Champney wrote: I need to find out the amount of total VRAM and available VRAM in the current renderer before creating a large renderbuffer object, to make sure I don't choke the system in doing it. I know how to find the current renderer for a given display, but I want the current renderer for my NSOpenGLView. I can get to the core graphics context like this: //code is from my NSOpenGLView object, so self refers to an NSOpenGLView NSOpenGLContext* theContext = [self openGLContext]; void* the_CGLContext = [theContext CGLContextObj]; But that still doesn't get me to the renderer. What I want to to is get a handle to the current renderer's CGLRendererInfoObj, then use the call: CGLDescribeRenderer (theRendererInfoObj, theRendererInex, kCGLRPVideoMemory, deviceVRAM); But I can't for the life of me figure out how to get from my NSOpenGLView to the renderer's CGLRendererInfoObj. I don't want to assume that the openGL view is on the main display, as all the example code I can find does. Can somebody help me here? I'm going in circles with the documentation, and can't find an answer to this. On 10.5, you can get the CGLContext's CGLPixelFormat using CGLGetPixelFormat(), and get the CGLPixelFormat's kCGLPFARendererID using CGLDescribePixelFormat(). From that I think you should be able to identify the applicable renderer from among those available. That's the most direct route that I'm aware of, but you may be able to get a better recommendation from the experts on the Mac-OpenGL list. -- Troy Stephens Cocoa Frameworks Apple, Inc. ___ 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 [EMAIL PROTECTED]
Re: Getting a list of all classes, etc...
On 28/03/2008, at 3:23 AM, Ken Thomases wrote: On Mar 26, 2008, at 11:43 PM, Graham Cox wrote: I have a class that can contain different objects which all derive from a class R. The container can accept instances of any subclass of R. Each subclass of R implements a CLASS method for a particular feature, returning an array. The container needs to build an array which is the union of all the arrays returned by each subclass. Thus it needs to iterate through a list of all possible subclasses of R, combining the arrays as it goes. Problem is that not all possible subclasses of R are known until runtime, so I need a way to be able to get hold of such a list, based on the fact that they all inherit from R. Note that these are not instances of R, but classes. (I can get a list of instances I have right now, but that doesn't cover the possibility of another object instance derived from R being added after I already built the array). Hope this makes sense - any ideas? You seem to have solved this, but there might be a better way: Implement +initialize on class R. Reading the docs on +initialize, you'll find that it's called for subclasses of R, too, if those subclasses don't override +initialize. Even if a subclass does override +initialize, you can make it a part of the design contract that they must call [super initialize]. (Yes, that goes against a suggestion in the docs, but in this case you're doing it with eyes open for a specific purpose.) So, now you have arranged that R's +initialize is called for R and every one of its subclasses. In that method, you can use self to refer to the actual (sub)class being initialized and do whatever is appropriate from there. The problem with using initialize is that it's only guaranteed to be sent just before the first message is sent to that class (which might not be at all if the class isn't used). - Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSMapTable with pointer keys ?
On Mar 27, 2008, at 18:17 , Guillaume Laurent wrote: On Mar 27, 2008, at 17:54 , A.M. wrote: I think you would have an easier time with NSMutableDictionary and [NSValue valueWithPointer:x] as the key. Thanks, I'll try that too. Indeed, that seem to be the simplest solution. I couldn't get NSMapTable to work at all in that case, kinda frustrating. -- Guillaume http://telegraph-road.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Is @constantstring pointer equal to @constantstring a guarantee?
On Mar 27, 2008, at 4:20 PM, Nathan Vander Wilt wrote: So does that mean once I'm up at the Cocoa level, that constant strings *are* guaranteed to have the same pointer if their contents are the same? What is unique and what is a module in this context? They might be unique, they might not. It might change over time or in context of usage. And it may change if you suddenly decide that one of those global constant strings really needs to be configurable at runtime. Best not to rely upon it. In general, -isEqual*: methods are optimized to check for pointer identity equality, if it is a significant optimization. Certainly, the cost of a msgSend() is greater than a pointer equality test, but likely not in any significant fashion. Instruments or Shark can, of course, answer whether or not it matters. 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 [EMAIL PROTECTED]
Re: NSScroller question
On Mar 27, 2008, at 4:26 PM, [EMAIL PROTECTED] wrote: Thanks, but the corner view is the right side corner of the header view, right? I was talking about the small view just below it, on top of the vertical slider and part of the slider itself. It's a tiny view of about 2 pixels height. I believe it corresponds to NSScrollerNoPart, but I'm not sure. (By slider I take it you really mean scroller, as NSSlider is something else entirely. :-) An NSScroller (currently) has no subviews, but if your aim is to add one or more accessory views above the scroller, that can be done by subclassing NSScrollView. The key is to override NSScrollView's -tile method to invoke [super tile], and then adjust the layout to accommodate your accessory subview(s). Figure out where you want your accessory subview(s) to go, set their frame(s), and change the ScrollView's verticalScroller's frame (shrink and move down, since ScrollViews are flipped) to make room for them. On Thu, Mar 27, 2008 at 9:53 PM, Troy Stephens [EMAIL PROTECTED] wrote: On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote: Hi, NSScroller has a small view, by default two pixels high, just above the scroller and below the NSTableHeaderView's corner view. How can I get at this view? If you look at the XCode interface you can see they have put an icon in this view (the one that splits the editor view) and made it larger. I would like to remove the view completely so the scroller goes all the way up to the edge of the corner view. This question has been addressed before in the archives, but unfortunately the link pointing to an answer is no longer valid. Thanks. F. See NSTableView.h: /* Get and set the cornerView. The cornerView is the view that appears directly to the right of the headerView above the vertical NSScroller. The scroller must be present for the cornerView to be shown. Calling - setCornerView: may have the side effect of tiling the enclosingScrollView to accomodate the size change. The default value is an internal class that properly fills in the corner. */ - (void)setCornerView:(NSView *)cornerView; - (NSView *)cornerView; -- Troy Stephens Cocoa Frameworks Apple, Inc. -- Troy Stephens Cocoa Frameworks Apple, Inc. ___ 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 [EMAIL PROTECTED]
Re: A Tab after 4 SPACEs
On 27 Mar 2008, at 16:12, Gerriet M. Denkmann wrote: Current I am using: NSString *dummyString = [ NSString stringWithUTF8String: ]; NSTextView *dummyTextView = [ [ NSTextView alloc ] initWithFrame: NSMakeRect(0,0,1e4,1e4) ]; [ dummyTextView setString: dummyString ]; [ dummyTextView setFont: usedFont ]; NSLayoutManager *dummyLayoutManager = [ dummyTextView layoutManager ]; [ dummyLayoutManager setUsesScreenFonts: useScreenFont ]; unsigned int length = [ dummyString length ]; NSRange glyphRange = [ dummyLayoutManager glyphRangeForCharacterRange: NSMakeRange(0,length) actualCharacterRange: NULL ]; unsigned int glyphIndex = glyphRange.location; NSTextContainer *aTextContainer = [ dummyLayoutManager textContainerForGlyphAtIndex: glyphIndex effectiveRange: NULL ]; NSRect boundingRect = [ dummyLayoutManager boundingRectForGlyphRange: glyphRange inTextContainer: aTextContainer]; [dummyTextView release]; float widtOfDummyString = boundingRect.size.width; This looks incredible clumsy. Do you know of any better way? How about the following (largely untested; I did check that the glyph returned seemed sane): NSGlyph glyph = [usedFont glyphWithName:@space]; NSSize size; [usedFont getAdvancements:size forGlyphs:glyph count:1]; (space is the standard PostScript name for the space glyph; see, e.g. http://www.adobe.com/devnet/opentype/archives/glyph.html) Alternatively you could use the Core Text function CTFontGetGlyphsForCharacters() (but you'd need a CTFontRef rather than an NSFont), or you could implement a lightweight NSGlyphStorage and use either the shared NSGlyphGenerator or the one from your layout manager. Kind regards, Alastair. -- http://alastairs-place.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 [EMAIL PROTECTED]
Subverting the first responder chain
I am implementing a custom NSView subclass (actually a simple subclass of NSOpenGLView) that implements -keyDown: in order to respond to user typing. Typically, this works great. However, I have a few menu items which respond to atypical hotkeys (e.g. one responds to space, another to option+X). In this case, I've found that the view gets a -keyDown: event, which it dutifully handles, and the menu hotkey is never handled. I'd prefer it if the menu action were triggered and no -keyDown: event were generated, and that's exactly what happens with more typical menu hotkeys like command+letters. But my view doesn't know what is in the menubar and so, without adding a lot of ugly special-case code, from within the view's -keyDown: handler, it would be difficult to know whether I need to send the event to the next responder or handle the key myself. Is there any elegant solution to this problem? The last thing I want to do is reimplement hotkey handling on my own, but I can't think of any workarounds to this issue that don't involve my view taking on a lot of extra knowledge about what's in the menubar, or completely hacking the responder chain in some ugly way. It seems that I can't forward on to the next responder and then ask did you handle it?—if the responder chain fails to handle the event, apparently it just calls -noResponderFor: on the window and that is that—there's no return value of YES or NO or anything like that. Help...! ___ 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 [EMAIL PROTECTED]
Re: NSScroller question
Yes, I meant scroller, not slider. Just had a glass of wine too much :-) Actually I don't want to add an accessory view, I want to get rid of the one that appears to be there by default. I have attached a screenshot showing what I'm talking about. The yellow part is the knob, drawn by filling the rect return by calling [self rectForPart:NSScrollerKnob]. The green part is the slot, [self rectForPart:NSScrollerKnobSlot]. The white part above the slot is by default black, but here I made it white by filling the rect returned by calling [self rectForPart:NSScrollerNoParts]. I can move the knob/slot upwards by tampering with their designated rects (rect.origin.y -= 5), thus hiding the white part. But that messes up the drawing when the view is updated. I figured the white part was a view, but since you are telling me NSScroller has no subviews I really don't know what to think. Maybe there is something wrong with my implementation? @implementation TestScroller - (void)drawRect:(NSRect)rect { [self drawKnobSlot]; [self drawKnob]; } - (void)drawKnob { NSRect rect = [self rectForPart:NSScrollerKnob]; [[NSColor yellowColor] set]; [NSBezierPath fillRect:rect]; } - (void)drawKnobSlot { NSRect rect = [self rectForPart:NSScrollerKnobSlot]; [[NSColor greenColor] set]; [NSBezierPath fillRect:rect]; } @end On Fri, Mar 28, 2008 at 12:41 AM, Troy Stephens [EMAIL PROTECTED] wrote: On Mar 27, 2008, at 4:26 PM, [EMAIL PROTECTED] wrote: Thanks, but the corner view is the right side corner of the header view, right? I was talking about the small view just below it, on top of the vertical slider and part of the slider itself. It's a tiny view of about 2 pixels height. I believe it corresponds to NSScrollerNoPart, but I'm not sure. (By slider I take it you really mean scroller, as NSSlider is something else entirely. :-) An NSScroller (currently) has no subviews, but if your aim is to add one or more accessory views above the scroller, that can be done by subclassing NSScrollView. The key is to override NSScrollView's -tile method to invoke [super tile], and then adjust the layout to accommodate your accessory subview(s). Figure out where you want your accessory subview(s) to go, set their frame(s), and change the ScrollView's verticalScroller's frame (shrink and move down, since ScrollViews are flipped) to make room for them. On Thu, Mar 27, 2008 at 9:53 PM, Troy Stephens [EMAIL PROTECTED] wrote: On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote: Hi, NSScroller has a small view, by default two pixels high, just above the scroller and below the NSTableHeaderView's corner view. How can I get at this view? If you look at the XCode interface you can see they have put an icon in this view (the one that splits the editor view) and made it larger. I would like to remove the view completely so the scroller goes all the way up to the edge of the corner view. This question has been addressed before in the archives, but unfortunately the link pointing to an answer is no longer valid. Thanks. F. See NSTableView.h: /* Get and set the cornerView. The cornerView is the view that appears directly to the right of the headerView above the vertical NSScroller. The scroller must be present for the cornerView to be shown. Calling - setCornerView: may have the side effect of tiling the enclosingScrollView to accomodate the size change. The default value is an internal class that properly fills in the corner. */ - (void)setCornerView:(NSView *)cornerView; - (NSView *)cornerView; -- Troy Stephens Cocoa Frameworks Apple, Inc. -- Troy Stephens Cocoa Frameworks Apple, Inc. attachment: Picture 2.png___ 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 [EMAIL PROTECTED]
Re: error strings in NSPropertyListSerialization
On 27 Mar '08, at 6:10 PM, B.J. Buchalter wrote: I am writing code that is linked to the 10.4u SDK. Does this mean that I need to release the string? Yes. What happens if my app is run under 10.5? Cocoa detects that your code was linked with the 10.4 SDK and follows the old behavior. (Otherwise all apps that did do the right thing in the past would crash when run under 10.5.) If I move to the 10.5 SDK, does that mean that I must NOT release the string? Right. If you build your app for 10.5 then you need to start following the correct/new behavior. —Jens 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 [EMAIL PROTECTED]
CGContextReplacePathWithStrokedPath problem?
I'm using CGContextReplacePathWithStrokedPath to get an outline of a stroke, but it seems to ignore the current line cap, join and dash settings (it does thankfully honour the line width though, so it's not entirely useless). Can someone confirm that, or am I doing something wrong? -- S.O.S. ___ 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 [EMAIL PROTECTED]
Re: Static in Subclasses
On Mar 27, 2008, at 5:17 PM, [EMAIL PROTECTED] wrote: Date: Thu, 27 Mar 2008 14:44:17 -0600 From: Justin Giboney [EMAIL PROTECTED] Subject: Static in Subclasses To: Cocoa Developers cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes I need to create a series of classes that implement the Singleton design pattern. These classes have a lot of similar methods (I am trying to create a series of DAOs see: http://en.wikipedia.org/wiki/Data_Access_Object) . I was thinking that it would be best to create a super class, and a series of subclasses to that super class. The problem I am running upon is that the Singleton pattern requires a static variable. How can I get a variable that is static to each subclass, but that is declared in the super class? for example I tried this. snip I had a similar problem, and I addressed it by implementing a class cluster in which each of the private subclasses was a singleton. To handle the static variable issue, I just created a static NSDictionary in the source file in which the subclass identifier was the key, and the singleton instance was the value. Justin, I'll send you my source files privately to avoid making this message too long, but anyone else who wants to see what I did should feel free to mail me and ask. -Jon ___ 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 [EMAIL PROTECTED]
Re: NSScroller question
On Fri, Mar 28, 2008 at 1:17 AM, [EMAIL PROTECTED] wrote: The white part above the slot is by default black, but here I made it white by filling the rect returned by calling [self rectForPart:NSScrollerNoParts]. [self rectForPart:NSScrollerNoPart] simply returns a rect in the scroller where a click will have no effect. Those pixels are, however, part of the slot. Hamish ___ 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 [EMAIL PROTECTED]
Re: CGContextReplacePathWithStrokedPath problem?
Never mind, I was doing something wrong - it does honour all of those settings ;-) Apologies for doubting Quartz's engineers! (BTW, an aside: since Quartz has the ability to do this sort of bezier curve fitting, how about exposing more of it in the API? It would be great to be able to unflatten a bezier curve without using difficult curve fitting code (e.g. graphics gems), some of which is very tricky to get working well). -- S.O.S. On 28 Mar 2008, at 12:20 pm, Graham Cox wrote: I'm using CGContextReplacePathWithStrokedPath to get an outline of a stroke, but it seems to ignore the current line cap, join and dash settings (it does thankfully honour the line width though, so it's not entirely useless). Can someone confirm that, or am I doing something wrong? -- S.O.S. ___ 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/graham.cox%40bigpond.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Is @constantstring pointer equal to @constantstring a guarantee?
On Thu, Mar 27, 2008 at 9:16 PM, Jens Alfke [EMAIL PROTECTED] wrote: The linker coalesces multiple identical string constants into a single value in the data segment. However, you can still end up with multiple copies if your code was linked in separate pieces and then joined together. Prior to Xcode 3.0 that used to happen when using ZeroLink — in fact, once or twice I've had my code crash when run with ZeroLink because I'd inadvertently used pointer comparison instead of isEqualToString: somewhere. Xcode 3.0 doesn't have ZeroLink anymore, but the details of how your program gets linked together are not something you should be relying on. But it still makes sense to me that when I'm providing NSString constants to be used as they are in the case of an NSError's userInfo dictionary, for example, that pointer comparison is still valid. Of course I wouldn't do it for places where I expect arbitrarily-provided strings to be passed to my method, but I typically make my string constants opaque. Is this just in general a Bad Idea(TM)? --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Subverting the first responder chain
On Mar 27, 2008, at 7:52 PM, John Stiles wrote: I am implementing a custom NSView subclass (actually a simple subclass of NSOpenGLView) that implements -keyDown: in order to respond to user typing. Typically, this works great. However, I have a few menu items which respond to atypical hotkeys (e.g. one responds to space, another to option+X). In this case, I've found that the view gets a -keyDown: event, which it dutifully handles, and the menu hotkey is never handled. I'd prefer it if the menu action were triggered and no -keyDown: event were generated, and that's exactly what happens with more typical menu hotkeys like command+letters. But my view doesn't know what is in the menubar and so, without adding a lot of ugly special-case code, from within the view's -keyDown: handler, it would be difficult to know whether I need to send the event to the next responder or handle the key myself. Is there any elegant solution to this problem? The last thing I want to do is reimplement hotkey handling on my own, but I can't think of any workarounds to this issue that don't involve my view taking on a lot of extra knowledge about what's in the menubar, or completely hacking the responder chain in some ugly way. It seems that I can't forward on to the next responder and then ask did you handle it?—if the responder chain fails to handle the event, apparently it just calls -noResponderFor: on the window and that is that—there's no return value of YES or NO or anything like that. From http://developer.apple.com/documentation/Cocoa/Conceptual/ EventOverview/HandlingKeyEvents/chapter_6_section_4.html: An application routes a key-equivalent event by sending it first down the view hierarchy of a window. The global NSApplication object dispatches events it recognizes as potential key equivalents (based on the presence of modifier flags) in its sendEvent: method. It sends a performKeyEquivalent: message to the key NSWindow object. [...] If no object in the view hierarchy handles the key equivalent, NSApp then sends performKeyEquivalent: to the menus in the menu bar. So, NSApplication requires modifier flags on the key event to recognize it as a potential key equivalent. Unfortunately, I find no documented way of changing the application object's criteria for recognizing key equivalents. So, I think you'll need to subclass NSApplication, override sendEvent:, check for key events which you think should be candidate key equivalents, and pass them to the key window and then the menu bar via performKeyEquivalent:. If either returns YES, stop processing the event. Otherwise, pass the event to [super sendEvent:]. Cheers, Ken___ 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 [EMAIL PROTECTED]
Re: Is @constantstring pointer equal to @constantstring a guarantee?
On Mar 27, 2008, at 9:41 PM, Kyle Sluder wrote: But it still makes sense to me that when I'm providing NSString constants to be used as they are in the case of an NSError's userInfo dictionary, for example, that pointer comparison is still valid. Of course I wouldn't do it for places where I expect arbitrarily-provided strings to be passed to my method, but I typically make my string constants opaque. Is this just in general a Bad Idea(TM)? I think so. There's no telling if somebody has copied the string on its way from where you stuff it in the dictionary to where you're comparing it. Even if immutable string classes optimize copy... methods to be the equivalent of retain, there's no guarantee that somebody didn't do stringWithString: or whatever to circumvent that. Cheers, Ken ___ 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 [EMAIL PROTECTED]
embed screen sharing in a cocoa app?
With 10.5's new screen sharing ability is there away to embed screen sharing into my app? I would like to pop up a window in my cocoa app that allows a user to remote view or control the desktop of another mac. I know I can launch the screen sharing app externally with vnc:// Thanks, Adam ___ 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 [EMAIL PROTECTED]
Re: Subverting the first responder chain
Wow, this sounds like a disaster. Maybe in my -keyDown: call I can walk the menus in the menu bar and call -performKeyEquivalent on all of them. It's probably not fast :| I was in the process of writing code that stores the menu bar's key equivalents in a hash table and checks the hash table before handling -keyDown:, maybe I'll just keep doing that. It's gross but I guess all the potential solutions are gross. Ken Thomases wrote: On Mar 27, 2008, at 7:52 PM, John Stiles wrote: I am implementing a custom NSView subclass (actually a simple subclass of NSOpenGLView) that implements -keyDown: in order to respond to user typing. Typically, this works great. However, I have a few menu items which respond to atypical hotkeys (e.g. one responds to space, another to option+X). In this case, I've found that the view gets a -keyDown: event, which it dutifully handles, and the menu hotkey is never handled. I'd prefer it if the menu action were triggered and no -keyDown: event were generated, and that's exactly what happens with more typical menu hotkeys like command+letters. But my view doesn't know what is in the menubar and so, without adding a lot of ugly special-case code, from within the view's -keyDown: handler, it would be difficult to know whether I need to send the event to the next responder or handle the key myself. Is there any elegant solution to this problem? The last thing I want to do is reimplement hotkey handling on my own, but I can't think of any workarounds to this issue that don't involve my view taking on a lot of extra knowledge about what's in the menubar, or completely hacking the responder chain in some ugly way. It seems that I can't forward on to the next responder and then ask did you handle it?—if the responder chain fails to handle the event, apparently it just calls -noResponderFor: on the window and that is that—there's no return value of YES or NO or anything like that. From http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/chapter_6_section_4.html: An application routes a key-equivalent event by sending it first down the view hierarchy of a window. The global NSApplication object dispatches events it recognizes as potential key equivalents (based on the presence of modifier flags) in its sendEvent: method. It sends a performKeyEquivalent: message to the key NSWindow object. [...] If no object in the view hierarchy handles the key equivalent, NSApp then sends performKeyEquivalent: to the menus in the menu bar. So, NSApplication requires modifier flags on the key event to recognize it as a potential key equivalent. Unfortunately, I find no documented way of changing the application object's criteria for recognizing key equivalents. So, I think you'll need to subclass NSApplication, override sendEvent:, check for key events which you think should be candidate key equivalents, and pass them to the key window and then the menu bar via performKeyEquivalent:. If either returns YES, stop processing the event. Otherwise, pass the event to [super sendEvent:]. Cheers, Ken ___ 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 [EMAIL PROTECTED]
Re: Is @constantstring pointer equal to @constantstring aguarantee?
On 27 Mar '08, at 7:59 PM, Kyle Sluder wrote: On Thu, Mar 27, 2008 at 10:55 PM, Jeff Laing [EMAIL PROTECTED] wrote: What confuses me is that people keep talking about @constant as though it were a 'string constant' Its not, it's an Objective-C object that you can send messages to. [snip] What is the subtlety here that I must be missing? @ strings are actually instances of an immutable private NSString subclass. I think it's called _NSConstantString or some such. Yup. And they're not allocated on the heap; they're stored in the executable itself, although their memory layout is that of a real Obj-C object. The compiler tags them in such a way that the linker will coalesce identical ones into a single value. Of course this is an implementation detail. Yup. Don't rely on this behavior. —Jens 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 [EMAIL PROTECTED]