NSDictionary mutability test
There are a number of posts detailing with the ethics of the issue of determining an object's mutability. eg: http://www.cocoabuilder.com/archive/message/cocoa/2004/7/7/73 Does anyone have a current informed pragmatic opinion on how to deal with the following example? I am not trying to determine program flow by determining mutability, merely trying to limit the number of self inflicted injuries. The following never seems to assert, regardless of whether dict is mutable or not. NSAssert([dict isKindOfClass:[NSMutableDictionary class]], @dict is not mutable); I know that it is my responsibility to remain aware of an object's allocated class but sometimes I find myself wanting. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: NSDictionary mutability test
On 8 Dec 2008, at 18:53, Sherm Pendley wrote: On Dec 8, 2008, at 12:38 PM, [EMAIL PROTECTED] wrote: I am aware of why the assertion is never applied but the thread I referenced was several years old and I was hoping that there had been some progress on this. Your use of the word progress implies that something is broken and needs to be fixed. That is not the case. I cannot see the harm in requesting if anyone has new insights into old issues. I was using this assertion (written some time ago in ignorance) and wasted an afternoon tracking down the fact that it didn't work. It does work - it does the job it's designed to do. Maybe the only solution is to set up an exception handler. No, the solution is to not try to test for mutability. Such tests don't work because they're not *supposed* to work - code that tries to do such things is broken as designed. And no, it's not an ethical issue. Writing broken code isn't a question of good and evil, it's simply a question of what works and doesn't work. I would disagree. I see nothing wrong with the logically necessity of testing for mutability. It's just a property. sherm-- Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: NSDictionary mutability test
On 8 Dec 2008, at 19:05, I. Savant wrote: I was using this assertion (written some time ago in ignorance) and wasted an afternoon tracking down the fact that it didn't work. It does work - it does the job it's designed to do. I'll join the fray on this one. :-) I agree with you, Sherm, to a point. It works (does what it's designed to do), but because of the special case of class clusters, it'd be handy in some cases to be able to ask an object if it -isMutable. Absolutely. Maybe the only solution is to set up an exception handler. No, the solution is to not try to test for mutability. Such tests don't work because they're not *supposed* to work - code that tries to do such things is broken as designed. And no, it's not an ethical issue. Writing broken code isn't a question of good and evil, it's simply a question of what works and doesn't work. This is the most salient point. Either you (the developer) created the dictionary or it was handed to you. If you created it, you should know whether it is mutable. If you did not, the documentation (if it exists) and the method signature should tell you all you need to know. The only thing you could consider broken is if the method promises an immutable object but gives you a mutable one (or vice-versa). If there's ever an ambiguous situation and you need to enforce one or the other, make a -copy or -mutableCopy of the object to be sure, and rid yourself of the worry. This is all fine and dandy but the original post makes it clear that the mutability test is being applied in an NSAssert(). We are testing for broken promises and faulty assumptions. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: NSDictionary mutability test
Thanks for the lateral insight. Ran a quick test and it looks as if the defective NSAssert([dict isKindOfClass:[NSMutableDictionary class]], @dict is not mutable); can be recomposed as NSAssert([dict classForCoder] == [NSMutableDictionary class], @dict is not mutable); The recomposed assert catches the fault condition that the original missed. Very useful, but given the nature of this I would hesitate to cook up an -isMutable category method. By the way, putting isKindOfClass: NSMutableDictionary class into google code search implies that everyone is at it. [EMAIL PROTECTED] wrote: This is explained in the thread you referenced. All NSDictionary objects are instances of NSCFDictionary. Thus the only way to check if they are mutable through public API is to try mutating them and see if Cocoa throws a hissy fit. You can use -classForCoder and that will give you either NSDictionary or NSMutableDictionary. This is a public API but the result is not documented to be useful in this manner, so don't use this in any shipping app. (Although given the need for archives to remain backwards compatible I would not expect it to ever change.) However it could be handy for debugging purposes. Mike Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: NSDictionary mutability test
On 8 Dec 2008, at 21:25, Bill Bumgarner wrote: On Dec 8, 2008, at 11:53 AM, [EMAIL PROTECTED] wrote: I would disagree. I see nothing wrong with the logically necessity of testing for mutability. It's just a property. The AppKit and Foundation were designed with the decision to not allow for differentiation between mutable and immutable versions of a class cluster at runtime. This decisions was purposeful, explicit, and intentional. I find this an interesting point. Why was such a decision made? It seems counter intuitive. Thus, any code that tries to influence behavior based upon detecting mutable vs. immutable instances will be counter to the design patterns of the AppKit and Foundation. And it will be problematic. As has been noted, the AppKit/ Foundation APIs are written such that a method declared as returning (NSDictionary*) will not have said dictionary modified after the fact. Writing code that detects mutability and then mutates, if possible, would violate this contract and will cause unpredictable, potentially crashy, behavior. If the intention is to only use this for debugging purposes and to never influence at runtime behavior based on the mutability of an object, then the intention is more reasonable. However, this is still problematic specifically because many classes may return a mutable object as the result of calling a method that is declared as returning an instance of the immutable parent. Thus, such code can really only be reliable when limited to testing the objects produced by your own code. Potentially valuable, but only of a limited nature. b.bum Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: NSDictionary mutability test
Thanks for the insight into this. Some subtle stuff here. On 8 Dec 2008, at 21:54, Bill Bumgarner wrote: On Dec 8, 2008, at 1:43 PM, [EMAIL PROTECTED] wrote: This decisions was purposeful, explicit, and intentional. I find this an interesting point. Why was such a decision made? It seems counter intuitive. Performance An NSMutableDictionary instance can be returned from a method declared as returning (NSDictionary*) without risk that the client is going to go and change the contents behind your back. If test for mutability were common, then all kinds of methods across the 'kits would have to -copy the return value and, potentially, deeply. Is this a bit like the emperor's new clothes? As long as everyone says its an NSDictionary then it matters not if its an NSMutableDictionary! A sort of mutually agreed insurance. Simplicity What does mutable even mean in the case of a collection? If an NSArray of NSDictionaries is mutable, does that also mean the NSDictionaries contained within are mutable? The current design point is that pretty much everything is immutable unless (a) you specifically created a mutable data structure or (b) the 'kit explicitly returned a mutable data structure. This reminds me of the memory retain/release rules (if you alloc it you release it etc). If these points aren't already in the docs already then they wouldn't be out of place there. Reliability Having lots of if (mutable) this else that decision points would reduce the reliability of code in that it would increase the testing load.Example: Unit tests would have to explicitly test the code for both the immutable vs. mutable variants. And that doesn't consider the mutable container vs. immutable contents potential myriad of combinations. b.bum Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
NSTreeController, NSOutlineView, and a leak?
i've got an outline bound via a tree controller to a mutable set of my own proxy objects. when i create a new real object, i create a new proxy object and add it to the mutable set via the kvo compliant addObject: and all works well, and then i proceed to select the new object (line in the outline view). this all works as expected and the new object shows up properly in the outline view. if i then undo the creation, i remove the proxy object from my mutable set via the kvo compliant removeObject. and this works fine... visually. however, my proxy object is not released and thus not deallocated. i discovered (after about a day and a half of debuging) that the tree controller was holding a reference to my proxy object as part of its selection, even tho the object had been removed from its bound set. i've been able to solve this by calling the tree controller's -setSelectedIndexPath: nil, prior to my removing my proxy from the bound set. is this expected behavior? or is this a bug that i should report via radar? thanx, 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]
MDQuery and searching within application package
My app has a number of document templates stored within the application package. The app adds these document templates to the metadata store itself via mdimport. Spotlight correctly locates and identifies the document UTI. When querying these documents with MDQuery - setSearchScopes: [NSArray arrayWithObjects:appPath, nil] I get zero results. Experimenting with Spotlight and mdfind -onlyin seems to suggest that even if data exists within the store you cannot query the package directly. However, results can be obtained by querying the applications enclosing folder. Is there a way to query the package and its subfolders directly? I have come across the com.apple.package UTI but am not certain if it is of any relevance to this situation. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: Writing Array of Dictionaries to Defaults (CFPreferences)
I will begin by saying that I figured this out at about 9:30 last night. On Dec 1, 2008, at 7:08 PM, [EMAIL PROTECTED] wrote: // Notifies of change of data in table view. Make sure to reflect changes in datasource. - (void)tableView:(NSTableView *)aTableView setObjectValue: (id)anObject forTableColumn:(NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { NSString *columnID = [aTableColumn identifier]; NSMutableArray *scheduleArray = [NSMutableArray arrayWithArray:_schedules]; // If deactivate time was edited, we create a new schedule with just that changed. if ([columnID isEqualToString:kScheduleDeactivateString]) { NSLog(@Deactivate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setDeactivate:(NSNumber *) [anObject intValue]]; What are you doing here? You have an object (anObject). Presumably you think it's an NSNumber. Then, you ask for its intValue, which returns... an int. An int is _not_ an object, of course. You then cast that int to an NSNumber*, which is almost certainly wrong. You then pass it to some method which is probably expecting a pointer to an actual object, not an int posing as a pointer. The reason for the undefined object here (anObject) is that this method is actually a delegate method of NSTableView. I was under the impression that the delegate methods must be used as is (the prototype anyway) because that's the message NSTableView is going to send to the delegate. Depending on what table column was edited (as per the aTableColumn parameter) I need the object (presumably an NSString* since all of the table fields are text fields) to be either an NSString* or an NSNumber*. I know intValue returns an int, and I'm perfectly aware that an int is not an object, that's obvious. I did think there was some bridging in place, however, for NSNumber, but you are right, there isn't. What I really needed was: [NSNumber numberWithInt:[anObject intValue]] After changing that part of the line, this part of the method worked without incident. } // If activate time was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleActivateString]) { NSLog(@Activate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setActivate:(NSNumber *) [anObject intValue]]; You do the same here. } // If name was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleNameString]) { NSLog(@Title anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setTitle:(NSString *)anObject]; } // Iterate through the array to create a new one of NSDictionaries, not schedules. NSMutableArray *tmpArray; You have declared a pointer, but you haven't set it to point to anything, let alone anything meaningful. It just contains garbage at this point. for (Schedule *schedules in scheduleArray) { [tmpArray addObject:[schedules toDictionary]]; You're calling methods on an uninitialized pointer. This will probably crash. If you're unlucky, the bug will be hidden by happenstance (tmpArray may happen to be nil because that's what was left on the stack). You needed to initialize tmpArray to point to an actual NSMutableArray: NSMutableArray* tmpArray = [NSMutableArray array]; NSLog(@Adding this to array %@, [schedules toDictionary]); } // Write the array to preferences in /Library/Preferences. CFPreferencesSetValue(ScheduleKey, (CFArrayRef)tmpArray, ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); Again, tmpArray doesn't contain anything meaningful. So, attempting to write it out will have undefined results -- probably the crash you're seeing. CFPreferencesSynchronize(ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); } The pref pane runs fine. I can add items which calls my addSchedule method and just adds a blank item to the array. When I edit the title, it appears to work fine from the gui, but nothing is written to the plist. If I edit the activate or deactivate fields then I get the following error and System Preferences crashes. 12/1/08 6:39:59 PM System Preferences[2301] Adding this to array { activate = 100; deactivate = 1130; name = New Schedule; } 12/1/08 6:39:59 PM System Preferences[2301] *** -[NSCFString stringValue]: unrecognized selector sent to instance 0x16e63740 Does anyone have any insight about writing array's of dicts to preferences? You were also right about the array, I forgot those two little keywords, a simple oversight. Instead of going through the mess of making an NSMutableArray and casting as a CFArrayRef, I decided to just make a CFArrayRef from the get go and ended
Writing Array of Dictionaries to Defaults (CFPreferences)
Hey All- I'm working on a Preference Pane for my app (System Preferences plugin) and need to write an array of dictionaries pulled from my NSTableView to defaults. I don't want to serialize it as data since I would like it to be editable from the command line as well (for easy network administration). I'm using CFPreferences because the preferences need to be read by the plugin, my daemon which runs as root, and a helper app the the daemon fires off for gui interaction and I therefore want the plist to be located in /Library/Preferences/. I've got strings and boolean values being written there just fine, but I can't seem to create this array of dicts and have it put anything in the plist. Here's my code: // Notifies of change of data in table view. Make sure to reflect changes in datasource. - (void)tableView:(NSTableView *)aTableView setObjectValue: (id)anObject forTableColumn:(NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { NSString *columnID = [aTableColumn identifier]; NSMutableArray *scheduleArray = [NSMutableArray arrayWithArray:_schedules]; // If deactivate time was edited, we create a new schedule with just that changed. if ([columnID isEqualToString:kScheduleDeactivateString]) { NSLog(@Deactivate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setDeactivate:(NSNumber *) [anObject intValue]]; } // If activate time was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleActivateString]) { NSLog(@Activate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setActivate:(NSNumber *) [anObject intValue]]; } // If name was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleNameString]) { NSLog(@Title anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setTitle:(NSString *)anObject]; } // Iterate through the array to create a new one of NSDictionaries, not schedules. NSMutableArray *tmpArray; for (Schedule *schedules in scheduleArray) { [tmpArray addObject:[schedules toDictionary]]; NSLog(@Adding this to array %@, [schedules toDictionary]); } // Write the array to preferences in /Library/Preferences. CFPreferencesSetValue(ScheduleKey, (CFArrayRef)tmpArray, ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); CFPreferencesSynchronize(ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); } The pref pane runs fine. I can add items which calls my addSchedule method and just adds a blank item to the array. When I edit the title, it appears to work fine from the gui, but nothing is written to the plist. If I edit the activate or deactivate fields then I get the following error and System Preferences crashes. 12/1/08 6:39:59 PM System Preferences[2301] Adding this to array { activate = 100; deactivate = 1130; name = New Schedule; } 12/1/08 6:39:59 PM System Preferences[2301] *** -[NSCFString stringValue]: unrecognized selector sent to instance 0x16e63740 Does anyone have any insight about writing array's of dicts to preferences? Thanks Ryan Harter http://www.ryanharter.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 [EMAIL PROTECTED]
Re: Writing Array of Dictionaries to Defaults (CFPreferences)
Thanks Steven- That's a helpful example, but does not work in my example. From my research of Apple's docs, NSUserDefaults, and the SharedDefaultsController can only save defaults to ~/Library/ Preferences and for the app that is running it (in your example case com.yourcompany.dictInDefaults, in mine com.ryanharter.speakermutepref), but since this is running from System Preferences, and the preferences are actually for a different application (my daemon and helper, com.ryanharter.speakermute and com.ryanharter.speakermutehelper respectively) and the defaults need to be stored in /Library/Preferences since they are not user specific I need to use CFPreferences. That's why I'm not using NSUserDefualts, but please let me know if my information is inaccurate. Any other thoughts? Thanks Ryan On Dec 2, 2008, at 9:08 AM, Steven Riggs wrote: Here's an example of how to do it with no code... http://www.stevenriggs.com/Site/Cocoa_Programming.html Good luck, Steven Riggs On Dec 1, 2008, at 8:08 PM, [EMAIL PROTECTED] wrote: Hey All- I'm working on a Preference Pane for my app (System Preferences plugin) and need to write an array of dictionaries pulled from my NSTableView to defaults. I don't want to serialize it as data since I would like it to be editable from the command line as well (for easy network administration). I'm using CFPreferences because the preferences need to be read by the plugin, my daemon which runs as root, and a helper app the the daemon fires off for gui interaction and I therefore want the plist to be located in / Library/Preferences/. I've got strings and boolean values being written there just fine, but I can't seem to create this array of dicts and have it put anything in the plist. Here's my code: // Notifies of change of data in table view. Make sure to reflect changes in datasource. - (void)tableView:(NSTableView *)aTableView setObjectValue: (id)anObject forTableColumn:(NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { NSString *columnID = [aTableColumn identifier]; NSMutableArray *scheduleArray = [NSMutableArray arrayWithArray:_schedules]; // If deactivate time was edited, we create a new schedule with just that changed. if ([columnID isEqualToString:kScheduleDeactivateString]) { NSLog(@Deactivate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setDeactivate:(NSNumber *) [anObject intValue]]; } // If activate time was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleActivateString]) { NSLog(@Activate anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setActivate:(NSNumber *) [anObject intValue]]; } // If name was edited, we create a new schedule with just that changed. else if ([columnID isEqualToString:kScheduleNameString]) { NSLog(@Title anObject = %@, anObject); [[scheduleArray objectAtIndex:rowIndex] setTitle:(NSString *)anObject]; } // Iterate through the array to create a new one of NSDictionaries, not schedules. NSMutableArray *tmpArray; for (Schedule *schedules in scheduleArray) { [tmpArray addObject:[schedules toDictionary]]; NSLog(@Adding this to array %@, [schedules toDictionary]); } // Write the array to preferences in /Library/Preferences. CFPreferencesSetValue(ScheduleKey, (CFArrayRef)tmpArray, ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); CFPreferencesSynchronize(ApplicationID, kCFPreferencesAnyUser, kCFPreferencesCurrentHost); } The pref pane runs fine. I can add items which calls my addSchedule method and just adds a blank item to the array. When I edit the title, it appears to work fine from the gui, but nothing is written to the plist. If I edit the activate or deactivate fields then I get the following error and System Preferences crashes. 12/1/08 6:39:59 PM System Preferences[2301] Adding this to array { activate = 100; deactivate = 1130; name = New Schedule; } 12/1/08 6:39:59 PM System Preferences[2301] *** -[NSCFString stringValue]: unrecognized selector sent to instance 0x16e63740 Does anyone have any insight about writing array's of dicts to preferences? Thanks Ryan Harter http://www.ryanharter.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/steven.riggs %40me.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests
propblems w/ outline view delegate and notifications
given the following sequence of events: 1) load a window (NSWindow subclass) from a nib using an NSWindowController subclass 2) the window contains an NSOutlineView, and the delegate of the outline view is the window 3) in the window's awakeFromNib call: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(gotTableColSizeChanged:) name: NSOutlineViewColumnDidResizeNotification object: outline]; 4) later on in awakeFromNib, set the outline's delegate to nil i've discovered, via breakpoints in the debugger and via the fact that my notification selector isn't called, that step 4 is removing my observer! and while now that i know this is happening, its been easy enough to work around, but i'm wondering if this is expected behavior? and if so, is it documented anywhere? if not, can anyone comment as to whether or not it is a bug (personally, i think it probably is, but i could be talked out of this). i will report this via radar if appropriate. thanx, 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: Regex
NSPredicate can handle ICU standard regex matches. More info in the NSPredicate docs. The following snippet validates a UUID. /* is UUID see http://www.stiefels.net/2007/01/24/regular-expressions-for-nsstring/ */ - (BOOL)isUUID { NSString *regex = @^(([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]) {4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12})$; // supported non standard regex format is at http://www.icu-project.org/userguide/regexp.html NSPredicate *regextest = [NSPredicate predicateWithFormat:@SELF MATCHES %@, regex]; return [regextest evaluateWithObject:self]; } Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: Cocoa-dev Digest, Vol 5, Issue 1904
At 12:02 PM -0800 11/6/08, ic wrote: Date: Thu, 6 Nov 2008 14:20:08 -0500 From: Eric Gorr [EMAIL PROTECTED] Subject: Re: A finished moving notification for a window? To: Cocoa Dev cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On Nov 6, 2008, at 1:52 PM, Eric Gorr wrote: It looks like the only way to get the behavior I want is to subclass NSWindow and override the mouse movement functions for the NSResponder. Well, this just got a little more complicated. The window does not mouseDown or mouseUp events if the user clicks in the title bar. I found an old thread: http://lists.apple.com/archives/cocoa-dev/2006/Oct/msg00141.html related to this issue, but there was no solution posted to the mailing list. i manage this with a subclass of nswindow as follows: register to receive the NSWindowWillMoveNotification notification upon receiving this notification, set an iVar windowIsMoving override send event as follows: - (void) sendEvent: (NSEvent*) theEvent { [super sendEvent: theEvent]; if ([self windowIsMoving]) if ([theEvent type] == NSLeftMouseUp) [self endMove]; } (don't forget to turn off windowIsMoving in endMove) 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: A finished moving notification for a window?
At 4:35 PM -0500 11/6/08, Eric Gorr wrote: On Nov 6, 2008, at 3:29 PM, [EMAIL PROTECTED] wrote: At 12:02 PM -0800 11/6/08, ic wrote: Date: Thu, 6 Nov 2008 14:20:08 -0500 From: Eric Gorr [EMAIL PROTECTED] Subject: Re: A finished moving notification for a window? To: Cocoa Dev cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes On Nov 6, 2008, at 1:52 PM, Eric Gorr wrote: It looks like the only way to get the behavior I want is to subclass NSWindow and override the mouse movement functions for the NSResponder. Well, this just got a little more complicated. The window does not mouseDown or mouseUp events if the user clicks in the title bar. I found an old thread: http://lists.apple.com/archives/cocoa-dev/2006/Oct/msg00141.html related to this issue, but there was no solution posted to the mailing list. i manage this with a subclass of nswindow as follows: register to receive the NSWindowWillMoveNotification notification upon receiving this notification, set an iVar windowIsMoving override send event as follows: How, exactly, did you do this? I have tried a couple of different things, but nothing seems to be working. If it matters (and I don't see why it should), I actually have a NSPanel. In my delegate for the NSPanel, as a test, I tried defining: - (void)windowWillMove:(NSNotification *)notification { NSLog( @windowWillMove ); } but this never gets called. I also defined windowDidMove and that gets called without any trouble. Any idea why windowWillMove would not get called? Next, in the awakeFromNib method in my controller, I tried calling: [[NSNotificationCenter defaultCenter] addObserver:myWindow selector:@selector(paletteWindowWillMove:) name:NSWindowWillMoveNotification object:nil]; but, the selector paletteWindowWillMove: in the subclass of my NSPanel, never gets called. Any idea why? from my NSWindow subclass's awakeFromNib: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(beginMove:) name: NSWindowWillMoveNotification object: self]; i have no idea if this will work with panel's, but i would think it would as a panel is a subclass of a window, but you would obviously have to subclass NSPanel instead of NSWindow. 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: A finished moving notification for a window?
At 5:25 PM -0500 11/6/08, Eric Gorr wrote: Apparently, NSPanel's don't get NSWindowWillMoveNotification's - at least I am not getting them in 10.5. Perhaps a bug? don't know. file a radar bug and see what response you get. 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]
Code signing validation
Hello list Having implemented code signing for my app I wanted to be able to do a quick visual check that things were as they should be. I used the following to display a code signing validation message in the app About window for both the application bundle and a couple of auxiliary executables. Has anyone else done anything similar, or hopefully, better? It would probably be a good idea to also check the signing identity. #import Cocoa/Cocoa.h typedef enum { CodesignUnrecognised = -2, CodesignError = -1, CodesignOkay = 0, CodesignFail = 1, CodesignInvalidArgs = 2, CodesignFailedRequirement = 3, } CodesignResult; @interface MGSCodeSigning : NSObject { NSString *_resultString; } @property (copy) NSString *resultString; - (CodesignResult)validateExecutable; - (CodesignResult)validatePath:(NSString *)path; - (CodesignResult)validateApplication; @end #import MGSCodeSigning.h #include dlfcn.h @implementation MGSCodeSigning @synthesize resultString = _resultString; /* validate executable */ - (CodesignResult)validateExecutable { Dl_info info; int errDlAddr = dladdr( (const void *)__func__, info ); if(errDlAddr == 0) { return CodesignError; } char *exec_path = (char *)(info.dli_fname); NSString *path = [NSString stringWithCString:exec_path encoding:NSUTF8StringEncoding]; return [self validatePath:path]; } /* validate this application */ - (CodesignResult)validateApplication { return [self validatePath:[[NSBundle mainBundle] bundlePath]]; } /* validate path */ - (CodesignResult)validatePath:(NSString *)path { self.resultString = nil; int status = CodesignError; @try { NSArray *arguments = [NSArray arrayWithObjects: @--verify, path, nil]; NSTask *task = [[NSTask alloc] init]; [task setArguments:arguments]; [task setLaunchPath:@/usr/bin/codesign]; [task setStandardOutput:[NSFileHandle fileHandleWithNullDevice]]; [task setStandardError:[NSFileHandle fileHandleWithNullDevice]]; [task launch]; [task waitUntilExit]; status = [task terminationStatus]; switch (status) { case CodesignOkay: self.resultString = NSLocalizedString(@Valid, @Codesign okay.); break; case CodesignFail: self.resultString = NSLocalizedString(@Invalid, @Codesign failed.); break; case CodesignInvalidArgs: self.resultString = NSLocalizedString(@Invalid arguments, @Codesign invalid arguments); break; case CodesignFailedRequirement: self.resultString = NSLocalizedString(@Failed requirement, @Codesign failed requirement.); break; default: self.resultString = NSLocalizedString(@Unrecognised response, @Codesign unrecognised response.); status = CodesignUnrecognised; break; } if (status != CodesignOkay) { NSLog(@codesign failure: %@, self.resultString); } [EMAIL PROTECTED] (NSException *e) { NSLog(@Exception launching codesign: %@, [e reason]); return CodesignError; } return status; } @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]
. Re: Code signing validation
I am aware of the -o kill flag but I am not sure that killing my code stone dead is what I require in this case. Any resource change, even a removed localisation would then be fatal. For me a string representation of the code signing is more of a sanity check. I just pass the -o kill flags to codesign. That way if the app has been tampered with it won't launch. Make sure you are using Xcode 3.1 or later so the codesigning is done after the stripping. Dave Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.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 [EMAIL PROTECTED]
Re: performSelectorOnMainThread and exceptions
At 6:51 PM -0500 10/27/08, Ken Thomases wrote: On Oct 27, 2008, at 4:05 PM, [EMAIL PROTECTED] wrote: if i call -[anObject performSelectorOnMainThread:aSelector withObject:nil waitUntilDone:NO] and then later throw an exception (of my own), which i catch, the deferred execution of aSelector never happens. note that the performSelectonOnMainThread, and the throw and catch are all in the same run of the run loop and are all in the main thread. is this a bug (seems like it to me) or proper/expected behavior. if i didn't catch the exception, i could understand this, but as i said, i am catching it. if this is proper behavior, can anyone offer me an explanation as to why? Sounds like a bug to me. File it with Apple http://bugreport.apple.com. Out of curiosity, since you're only trying to defer a message and everything's on the main thread, does it still happen with [anObject performSelector:aSelector withObject:nil afterDelay:0]? for the archives. so i built a very simple test application in preparation to filing a bug report and to try [anObject performSelector:aSelector withObject:nil afterDelay:0]. and lo and behold, my deferred method was executed using either deferred variants! so i revisited the issue in my app, and sure enough it is now working as i expected, ie, the deferred method is invoked, even when an exception is thrown. musta been brain freeze the first time around! :-( ken Regards, 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]
performSelectorOnMainThread and exceptions
if i call -[anObject performSelectorOnMainThread:aSelector withObject:nil waitUntilDone:NO] and then later throw an exception (of my own), which i catch, the deferred execution of aSelector never happens. note that the performSelectonOnMainThread, and the throw and catch are all in the same run of the run loop and are all in the main thread. is this a bug (seems like it to me) or proper/expected behavior. if i didn't catch the exception, i could understand this, but as i said, i am catching it. if this is proper behavior, can anyone offer me an explanation as to why? thanx, 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: performSelectorOnMainThread and exceptions
At 6:51 PM -0500 10/27/08, Ken Thomases wrote: On Oct 27, 2008, at 4:05 PM, [EMAIL PROTECTED] wrote: if i call -[anObject performSelectorOnMainThread:aSelector withObject:nil waitUntilDone:NO] and then later throw an exception (of my own), which i catch, the deferred execution of aSelector never happens. note that the performSelectonOnMainThread, and the throw and catch are all in the same run of the run loop and are all in the main thread. is this a bug (seems like it to me) or proper/expected behavior. if i didn't catch the exception, i could understand this, but as i said, i am catching it. if this is proper behavior, can anyone offer me an explanation as to why? Sounds like a bug to me. File it with Apple http://bugreport.apple.com. will do/ Out of curiosity, since you're only trying to defer a message and everything's on the main thread, does it still happen with [anObject performSelector:aSelector withObject:nil afterDelay:0]? i didn't try that. however, i've since re-architected somewhat and can't easily test in my app. i may try that before filing a bug report. ken Regards, 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: table bindings, value transformer per row?
thanx for this. i've been using the willDisplayCell: delegate method to swap formatters as necessary, but i'd never thought of using it to swap the cell's value! i will add this to my bag o' tricks for possible future use. for my current situation, i removed the use of the value transformer from my binding, and bound the column to different data in my model and apply appropriate formatter's as necessary. note that going this way doesn't impact sorting. thanx, ken At 6:26 PM -0700 10/17/08, Ron Lue-Sang wrote: Nope. No way to swap out the valuetransformer of the binding per row. You can use part of Keary's suggestion tho. Don't set a valuetransformer at all in the binding for the column. Use the willDisplayCell: delegate method to take the value out of the cell, apply your own value transformations based on the row or whatever, and then set the new value on the cell. Unfortunately, this setup will defeat the sorting behaviour Cocoa Bindings gives you for free. Our automatic support for sorting, for this column, will be wrong. I'd only suggest doing this for a column that's not sortable/filterable. Otherwise, you should really just add accessors to your model objects if you can (or create wrappers for them if you have to) that give you the transformed properties. -- RONZILLA On Oct 16, 2008, at 4:59 PM, mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: i was asking about the value transformer that is specified for the binding. i am aware that it is quite easy to change formatters. thanx anyway, ken At 5:49 PM -0600 10/16/08, Keary Suska wrote: On Oct 15, 2008, at 7:35 PM, mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: i've got a bound table view. is it possible to use a different value transformer based on which row of the table is being displayed/edited? and if so, how? Yes, you can. The formatter is a property of the cell, and not the column, per se. You need an object that is the tableview's delegate, then implement -tableView:willDisplayCell:forTableColumn:row:. NSCell has a -setFormatter: method for your convenience. I have used this successfully without error, but I haven't performance tested it. I don't suspect that it is much slower. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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: table bindings, value transformer per row?
i was asking about the value transformer that is specified for the binding. i am aware that it is quite easy to change formatters. thanx anyway, ken At 5:49 PM -0600 10/16/08, Keary Suska wrote: On Oct 15, 2008, at 7:35 PM, [EMAIL PROTECTED] wrote: i've got a bound table view. is it possible to use a different value transformer based on which row of the table is being displayed/edited? and if so, how? Yes, you can. The formatter is a property of the cell, and not the column, per se. You need an object that is the tableview's delegate, then implement -tableView:willDisplayCell:forTableColumn:row:. NSCell has a -setFormatter: method for your convenience. I have used this successfully without error, but I haven't performance tested it. I don't suspect that it is much slower. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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]
table bindings, value transformer per row?
i've got a bound table view. is it possible to use a different value transformer based on which row of the table is being displayed/edited? and if so, how? thanx, 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]
Changing system volume
Hi, Is there a method in Cocoa that I could use to set the system volume? I would use SetDefaultOutputVolume, but it is deprecated in 10.5. 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 [EMAIL PROTECTED]
Re: Problem redirecting NSLog() output to stderr
Thanks for the suggestions Mike. I had an intuition that my core Unix knowledge was wanting here. It turns out that a call to ftruncate(STDERR_FILENO, 0) does indeed do the job. Jonathan You can't detect that the stderr stream is no longer valid in these cases because, in fact, it *is* still valid. In UNIX, when you delete a file which some process still has open, that file doesn't actually go away. It remains on disk, and that process's file descriptor to it remains valid. Writes and reads continue to work as expected. Once the file descriptor is closed (or the process terminates, or the computer reboots, etc.) the file is finally removed from the disk. Rather than delete the file, it may work if you simply truncate it. New writes should then go to the end of the newly truncated file. If you really need to function after deletes (for example if you don't control the code that deletes the file, or you want to continue to function after the user trashes it from the Finder or something) then you can use kqueue to find out when something happens to the file, or even just poll it every few seconds if you can't rely on kqueue to be available on the filesystem in question. Mike Hello List My app consists of a GUI process, a daemon and a number of worker processes. Each of these processes has their stderr redirected via freopen() to the same log file. For the purposes of simple logging this arrangement works acceptably. There is a thread on why this should be: http://www.cocoabuilder.com/archive/message/cocoa/2003/6/16/3689 The user may however delete the shared log from the GUI. After this the daemon and worker process log output is lost. In those cases can I detect that the stderr stream is no longer valid? I have tried fcntl(), fileno(), fstat(), ftell() and feof() without success. My actual call to NSLog() is wrapped in a generic logging class. My only solution so far is to issue freopen(logfile, a, stderr) prior to each and every call to NSLog(). But this seems brutal. ___ 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]
Problem redirecting NSLog() output to stderr
Hello List My app consists of a GUI process, a daemon and a number of worker processes. Each of these processes has their stderr redirected via freopen() to the same log file. For the purposes of simple logging this arrangement works acceptably. There is a thread on why this should be: http://www.cocoabuilder.com/archive/message/cocoa/2003/6/16/3689 The user may however delete the shared log from the GUI. After this the daemon and worker process log output is lost. In those cases can I detect that the stderr stream is no longer valid? I have tried fcntl(), fileno(), fstat(), ftell() and feof() without success. My actual call to NSLog() is wrapped in a generic logging class. My only solution so far is to issue freopen(logfile, a, stderr) prior to each and every call to NSLog(). But this seems brutal. Jonathan ___ 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: Threading problem using AsyncSocket (Matthew Youney)
I don't know about your threading problem but surely the whole point of AsyncSocket is the Async bit. It is designed to attach itself to the runloop and remove the need for blocking sockets etc on threads. I use AsyncSocket extensively within the main thread and it can handle multiple connection without any problem. Hello list, This is my first attempt at threading with Cocoa, and I am having difficu= lty with my classes that use AsyncSocket. I am using DetachNewThreadSelector= : to detach my =91worker=92 thread, and I am instantiating my class that us= es AsyncSocket from within this thread. The problem is that the AsyncSocket delegates are never called. This class works just fine from the main thread. - (IBAction)RunTestButtonPressed:(id)sender { [NSThread detachNewThreadSelector: @selector(threadFunction:) toTarget: self withObject: recipe]; } - (void) threadFunction:(BeverageRecipe*)recipe { ClassContainingAsyncSocket* foo; int i=3D0; while (stuffTodo) { NSAutoreleasePool* autoReleasePool=3D[[NSAutoreleasePool alloc]init]; foo=3D[[ ClassContainingAsyncSocket alloc]init]; i=3D[foo readRegister:0]; //none of the AsyncSocket delegate= s =91fire!=92 [autoReleasePool release]; do more stuff=85. } } Does anyone have any idea what I am missing? Something fundamentally wro= ng? Thanks in advance for any and all assistance. 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: NSTextField Bug? Can't be!
Seems to me that this might be more to do with the responder chain. The NSTextField will update its stringValue when it resigns as first responder. An NSButton does not accept first responder status so the NSTextField never gets to resign first responder status. If you are using NSViewController call -commitEditing in your button click method. This will commit any pending edits. Otherwise send -makeFirstResponder: to the view's window with the window itself as the argument. Similar effect. This situation happens frequently. It's one good reason to always use NSViewController. Check out NSEditor (Informal Protocol) and NSEditorRegistration (Informal Protocol) for the low down. Jonathan. FROM : Seth Willits DATE : Tue Aug 12 10:28:30 2008 Right. I figure though that asking for stringValue grabs the text from the field editor, so why doesn't setEnabled do the same to commit current editing? Seems logical to me. I can't imagine a situation where you'd want text the user typed into a field to be ignored after they already typed it. -- Seth Willits On Aug 11, 2008, at 10:40 PM, Graham Cox wrote: I suspect it's because of the Field Editor. The text isn't really in the field, it's in the shared field editor. If the field is disabled, it won't be updated from the field editor because disabled means refuse input. Also, it may be that when a control that is using the field editor is disabled, it disconnects from the field editor and clears its contents. You could try calling -validateEditing on the field prior to disabling it, which should copy over the text content from the field editor so that the field indeed does have this value. hth, cheers, Graham On 12 Aug 2008, at 3:31 pm, Seth Willits wrote: If a text field has focus, you type blah blah blah into it, and then click a button which asks for its string value and disables the text field, you get blah blah blah back. If a text field has focus, you type blah blah blah into it, and then click a button which disables the text field first and then asks for its string value, you get an empty string... I can make up some reasoning in my head for why that'd make sense, but it just doesn't sit well with me. If the text is *IN THE FIELD* before the field is disabled, then clearly it should be considered its string value. I can't imagine this being a bug simply because *somebody* would have noticed and fixed it by now, but I can't understand why this would be desirable behavior. ___ 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]
Using performSelector: on super
Hello list My superclass (SuperSocket) provides a private method -close. My subclass overrides this private method as follows: - (void)close { SEL closeSelector = @selector(close); if ([SuperSocket instancesRespondToSelector:closeSelector]) { [super performSelector:closeSelector]; // seems to send to self } else { NSAssert (NO, @SuperSocket no longer responds to close message.); } // subclass additional code } If I am not mistaken this code appears to send the close selector to the self object. If [super performSelector:closeSelector] is replaced by [super close] then the super object receives the close message as expected. I know that [super respondsToSelector: closeSelector] is equivalent to [self respondsToSelector: closeSelector] as the methods tests the object as a whole (see NSObject Protocol Reference entry for respondsToSelector;); So is that the story here? Or am I on the wrong page entirely. ___ 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: Using performSelector: on super
Sorry for the inaccuracy. I am well aware that there is no such thing as a true private method in Objective-C, though it seems generally common to refer to such contraptions (A, B and Y's Cocoa Programming contains such usage, page 81). I of course mean that the SuperSocket class responds to the -close method but does not declare it in its interface file. -close is indeed declared as a method on a SuperSocket category defined within SuperSocket.m I was using performSelector: merely to keep the compiler content. Declaring a further accessible category on SuperSocket to announce the existence of -close accomplished the same thing. At least my initial lassitude in declaring that category ultimately decreased the sum total of my ignorance. No more super self confusion for me! On 5 Aug 2008, at 21:39, I. Savant wrote: On Tue, Aug 5, 2008 at 4:31 PM, James Bucanek [EMAIL PROTECTED] wrote: The OP did override -close in their subclass and were attempting to call [super close] from the subclass' -close method. The OP stated that they couldn't simply use [super close] because -close was private, which didn't make any sense to me. Yes, I was ignoring that part because I assumed it was just poorly phrased (and later corrected). Perhaps, Jonathan, you could elaborate on what leads you to believe the -close method is private? -- I.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: Using performSelector: on super
On 5 Aug 2008, at 23:38, James Bucanek wrote: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote (Tuesday, August 5, 2008 2:19 PM +0100): Sorry for the inaccuracy. No problem. I of course mean that the SuperSocket class responds to the -close method but does not declare it in its interface file. -close is indeed declared as a method on a SuperSocket category defined within SuperSocket.m I was using performSelector: merely to keep the compiler content. Declaring a further accessible category on SuperSocket to announce the existence of -close accomplished the same thing. Then let me make two points and one suggestion. In your original code, you had SEL closeSelector = @selector(close); if ([SuperSocket instancesRespondToSelector:closeSelector]) { ... This does not, as I think you believe, test to see if an object of the class SuperSocket responds to the -close message. In fact, it tests to see if the class object for SuperSocket responds to the +close message. SuperSocket is a reference to the single Class object defined for SuperSocket, it it not a proxy for an instance of the SuperSocket class. Are you sure about that James? The NSObject class reference for + instancesRespondToSelector: says: Returns a Boolean value that indicates whether instances of the receiver are capable of responding to a given selector. ... To ask the class whether it, rather than its instances, can respond to a particular message, send to the class instead the NSObject protocol instance method respondsToSelector:. The NSObject Protocol Reference for respondsToSelector: also chips in upon the subject: You cannot test whether an object inherits a method from its superclass by sending respondsToSelector: to the object using the super keyword. This method will still be testing the object as a whole, not just the superclass’s implementation. Therefore, sending respondsToSelector: to super is equivalent to sending it to self. Instead, you must invoke the NSObject class method instancesRespondToSelector: directly on the object’s superclass, as illustrated in the following code fragment. if ([MySuperclass instancesRespondToSelector:@selector(aMethod)]) { [super aMethod]; } But I have been wrong before! To determine if an instance of an object SuperSocket responds to a particular method, I believe that you'd have to use SuperSocket's Class object reference and use class_getInstanceMethod to determine if it actually implements a -close method. If you wanted to find out if any of its superclass' implemented it, you'd have to walk of the chain of parent Class objects until you hit NSObject. As for the compiler warning, that could easily be suppressed with (believe it or not) [(id)super close]; // superclass assumed to implement close Now that really would have saved everyone a lot of typing. I often cast to a specific object type, casting with id never occurred to me. If you really want your code to dynamically alter execution depending on whether the close method is implemented by the superclass, I would suggest something like try { [(id)super close]; // call superclass' -close, if implemented ... } catch { if (method not implemented exception) // code that gets called if superclass doesn't implement -close ... } -- Exception handling might be a bit excessive here I think. If I recall correctly It's quite a heavyweight object in Objective-C. James Bucanek ___ 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: NSTableView NSTrackingArea and mouse clicks
hi corbin, i understand ur explanation and it makes sense. and i see that the fix works in PhotoSearch. unfortunately, it doesn't solve all my problems. but at this point, i believe i may have a draw problem as i'm seeing the highlight being drawn twice. thanx, ken ps. i used the term toolbox because i wasn't sure if this was foundation or appkit, and just used an old term wrongly. sorry. At 1:42 PM -0700 7/25/08, Corbin Dunn wrote: Hi ken, It took me a minute to realize it, but what you describe below makes sense. Let me clarify what preparedCellAtColumn:row: does; this is the main funnel point that NSTableView uses to get a cell to do any operations (ie: drawing, type selection, etc). NSTableView's implementation gives you a cell set up with the correct state (ie: selected, etc). Now, what does the TrackableOutlineView app do? It *copies* this cell (and any state it had), and returns that copy in preparedCellAtColumn:row:. So, you mouse in, it copies the cell and starts returning that cell. If you click down, well, NSTableView never gets a chance to set the state, since you override preparedCellAtColumn:row:. Make sense? It is working correctly; it's not a bug in PhotoSearch or the framework (also -- we use the term AppKit or framework, but toolbox refers to another framework). Of course, you want it to not work that way. You want it to reflect the state that NSTableView sets. So, a quick hack: - (NSCell *)preparedCellAtColumn:(NSInteger)column row:(NSInteger)row { // We check if the selectedCell is nil or not -- the selectedCell is a cell that is currently being edited or tracked. We don't want to return our override if we are in that state. if ([self selectedCell] == nil (row == iMouseRow) (column == iMouseCol)) { NSCell *superCell = [super preparedCellAtColumn:column row:row]; [iMouseCell setHighlighted:[superCell isHighlighted]]; return iMouseCell; } else { return [super preparedCellAtColumn:column row:row]; } } .corbin thanx for the reply. i was pretty sure it wasn't my drawing code and after some more playing around i'm convinced of that. i've narrowed down my problem (and i can reproduce it in the PhotoSearch demo -- see below). the -[NSCell setHighlighted:] message does NOT get sent to a cell if a click occurs inside an NSTrackingArea for the cell/view. to see this problem in the PhotoSearch demo app, add the following 3 lines to the bottom of -[ImagePreviewCell addTrackingAreasForView:inRect:withUserInfo:mouseLocation:] : cellFrame.size.width /= 2; NSTrackingArea *area2 = [[NSTrackingArea alloc] initWithRect:cellFrame options:options owner:controlView userInfo:userInfo]; [controlView addTrackingArea:area2]; [area2 release]; also add an override of setHighlighted as follows: - (void) setHighlighted: (BOOL) value { NSLog(@%s: %d, __func__, value); [super setHighlighted: value]; } you can verify that the new tracking area is working because if you move the mouse into it, the info button changes. but if u click in this second tracking area, your override of setHighlighted does NOT get called. offhand, i would say that this doesn't sound like a bug in PhotoSearch, but rather a bug in the toolbox. would you agree? if you think this is a bug in PhotoSearch, can you suggest a solution? if this is in fact a toolbox bug, let me know and i'll report in radar; and also, could you suggest a work-around? thanx, ken At 7:44 AM -0700 7/25/08, Corbin Dunn wrote: On Jul 24, 2008, at 6:16 PM, [EMAIL PROTECTED] wrote: i have an NSTableView that uses a data source (no bindings, but i don't think this is relevant). one column uses a custom cell that is actually a subclass of NSTokenFieldCell (but i don't think this is relevant either). i draw this cell differently depending on whether or not the row it is in is the table's selected row. (and i only allow one row at a time to be selected.) if i don't use any NSTrackingAreas, everything works as i want/expect. however, if i set up some tracking rects for my custom cell, then things don't work properly. i am using the techniques from the sample PhotoSearch app. by don't work properly, what i mean is that if i select a row by clicking in one of the NSTrackingAreas, the cell draws as if the row isn't selected. if i don't click inside one of the tracking rects, but click elsewhere in the row, then my custom cell draws properly, ie in its highlighted state. since this is my first use of NSTrackingArea, i wouldn't be surprised if its something i'm doing. are there known interactions between NSTrackingArea a clicks in the tracking area? can anyone suggest how i can proceed? No; none --- it is probably something wrong with your cell drawing code. Can you post it here? I'll take a look at it. corbin (I wrote that demo -- note, I think there are a few bugs in the tracking area code
bug in PhotoSearch
corbin, i think there is another bug in PhotoSearch. in TrackableOutlineView mouseEntered, the call to [iMouseCell mouseEntered:] should be outside the if block that sets iMouseCell if needed. also, is there a specific reason for caching the cell in iMouseCell? i've done away with the caching in my app (and thus also don't have to override preparedCellAtColumn:row:), and now all my problems have gone away? my guess is that u were caching the cell for performance reasons... is that correct? or am i opening myself up for a future problem? 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]
NSTableView NSTrackingArea and mouse clicks
i have an NSTableView that uses a data source (no bindings, but i don't think this is relevant). one column uses a custom cell that is actually a subclass of NSTokenFieldCell (but i don't think this is relevant either). i draw this cell differently depending on whether or not the row it is in is the table's selected row. (and i only allow one row at a time to be selected.) if i don't use any NSTrackingAreas, everything works as i want/expect. however, if i set up some tracking rects for my custom cell, then things don't work properly. i am using the techniques from the sample PhotoSearch app. by don't work properly, what i mean is that if i select a row by clicking in one of the NSTrackingAreas, the cell draws as if the row isn't selected. if i don't click inside one of the tracking rects, but click elsewhere in the row, then my custom cell draws properly, ie in its highlighted state. since this is my first use of NSTrackingArea, i wouldn't be surprised if its something i'm doing. are there known interactions between NSTrackingArea a clicks in the tracking area? can anyone suggest how i can proceed? thanx for any suggestions, ken ps. this is on 10.5.4 with xcode 3.1 linked against the 10.5 sdk. ___ 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: NSPredicateEditorRowTemplate and ANY predicate
De: [EMAIL PROTECTED] On Jul 22, 2008, at 12:05 PM, Frédéric Testuz wrote: Hello, Is it possible to prepare a row template for a NSPredicateEditor in IB for a predicate like ANY keyPath == 'aValue' ? I'm not sure I understand your question. How is this different than just a normal OR type compound predicate? My question was too general. My model have is like this : Book --- Role --- Author A book can have many authors, an author can be on many books. The reason of the Role is that for a book, an author can be a writer, a drawer, a colourist, etc. So, to find the books with at least an author is John, I have this sort of predicate : ANY roles.author.name CONTAINS 'John' It works pretty well. But now I want a NSPredicateEditor to give me this sort of predicate. I don't find a way to do it in IB without subclassing NSPredicateEditorRowTemplate. Perhaps I have not see it. For info, I tried the subclassing and it works. ___ 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: [NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1
At 7:50 AM -0400 7/22/08, Kyle Sluder wrote: On Mon, Jul 21, 2008 at 5:02 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: lookupError]; This line right here requires an autorelease pool. Have you created one for your thread? It's apparent that you have a memory management issue somewhere in your code. Can you post more context? --Kyle Sluder kyle, thanx for the reply. yes, i do have an autorelease pool in place. i agree that it looks like some kind of memory management problem. the bothersome aspect is that this code used to work without any problems. and yes, i know thread problems aren't always reproducible, but the code has been in use problem free for sometime, probably going back as far as 10.5.3 or earlier. but i can't figure out what CFURL/NSURL is causing the problem. i'm not sure exactly what additional code is worth posting. given (what i believe is the relavent code): NSURL* lookupURL = [[NSURL alloc] initWithString: urlLookupString]; NSError* lookupError = nil; NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: lookupError]; ... [lookupURL release]; the error occurs during the processing of stringWithContentsOfURL; i would assume that it would retain the passed in url as long as it needs it; and i retain it (alloc init) before making the call and don't release the url until after my call to stringWithContentsOfURL. 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]
GetDblTime, 64-bit, and cocoa
i need to set a timer when i get a first mouse click and perform something if i don't get another click within the double click time. i found this old thread (from 2003) in the archives: http://www.cocoabuilder.com/archive/message/cocoa/2003/10/22/90328 from that thread, it would appear that the best solution may be to use GetDblTime. but this is a 32-bit only solution. is there a documented (cocoa) way to do this that may be future/64-bit safe? thanx, 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]
[NSString stringWithContentsOfURL:...], threads, and 10.5.4, xcode 3.1
i have been using +[NSString stringWithContentsOfURL:encoding:error:] in my app to obtain stock quotes from yahoo. i issue this in one (or more) threads to get values for one (or more) stocks. i'm not quite sure when this stopped working successfully, but it is definitely not working reliably on 10.5.4 with xcode 3.1 and with NO garbage collection. by not reliably i mean that i will quite frequently (but not always) get the following message on the console: *** -[CFURL _cfurl]: message sent to deallocated instance 0x290180d0 and the relevant stack trace is: #0 0x95ae3907 in ___forwarding___ #1 0x95ae3a12 in __forwarding_prep_0___ #2 0x95ab5d42 in CFURLCopyPath #3 0x92350d4e in createNotificationName #4 0x9235113c in __PrivateCookieStorageDeallocate #5 0x95a66788 in _CFRelease #6 0x923510d6 in __CFHTTPCookieStorageDeallocate #7 0x95a66788 in _CFRelease #8 0x92306c2d in _CFURLRequestDeallocate #9 0x95a66788 in _CFRelease #10 0x9230ac1b in __CFCachedURLResponse::SetRequest #11 0x9230ab0e in AddCacheTask #12 0x92308603 in __CFURLCache::CopyResponseForRequest #13 0x92307b38 in _CFURLConnectionSendCallbacks #14 0x92307573 in muxerSourcePerform #15 0x95a64615 in CFRunLoopRunSpecific #16 0x95a64cf8 in CFRunLoopRunInMode #17 0x9232ab42 in CFURLConnectionSendSynchronousRequest #18 0x952ac80b in +[NSURLConnection sendSynchronousRequest:returningResponse:error:] #19 0x9537afab in -[NSString initWithContentsOfURL:encoding:error:] #20 0x9537a51f in +[NSString stringWithContentsOfURL:encoding:error:] #21 0x00147f00 in +[StockSupport_Yahoo(PrivateUtilities) historicStockValue:asOfDate:error:] at StockSupport_Yahoo.mm:296 and the relevant snippet of my code is: NSURL* lookupURL = [[NSURL alloc] initWithString: urlLookupString]; NSError* lookupError = nil; NSString* csvString = [NSString stringWithContentsOfURL: lookupURL encoding: NSUTF8StringEncoding error: lookupError]; ... [lookupURL release]; i've worked around it for the time being by actually calling +[NSString stringWithContentsOfURL:encoding:error:] from my main thread, but not only does this slow down the app (since requests are now sequential), but it also prevents the user from aborting the requests (since the main/ui thread is now busy). can anyone explain the above error? can anyone indicate whether or not +[NSString stringWithContentsOfURL...] is thread safe? (i was under the impression that the foundation classes NSString, NSURL, and NSData were all thread safe, and as i said above, this used to work.) thanx for any help/answers/advice/etc. thanx, ken ps. it would take a fairly significant restructuring to use asynchronous NSURLConnection requests, so i'd like to avoid that if possible... especially since i had thought i had solved this problem by performing the requests in threads. ___ 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]
debugging runaway allocations under gc
We have an out of memory crasher in a gc app that we are trying debug, but I'm having a bit of difficulty bringing the correct tools to bear on the problem. I suspect that either we have some kind of runaway loop that's allocating us into oblivion, or we're outrunning the collector (I suspect the latter because the crash is never in exactly the same place, and no long processes are in progress). I have a reproducible case where we basically hammer the app with the same command over and over again (via script_, and memory usage does indeed increase (albeit slowly) over time, but at some stage it reaches a tipping point where the allocation just runs away quickly, and in the course of a couple seconds consumes all available resources and crashes. I tried running heap to see what was actually allocated and where, but after two hours pegging one of my four cores, heap is still churning. I tried using MallocDebug, but it's not compatible with gc (apparently). I tried using ObjectAlloc in instruments, but it generates so much data that instruments itself chokes on all the data and starts the machine churning (I was hoping for a windowed time facility as in Shark). I even tried conditional breakpoints on malloc to try to catch large allocations, but I don't think I've got the syntax of the condition right (I did manage to get it working using a debugger command for the breakpoint, but after a while it stops working). So now I'm looking for pointers on where I should be poking to try to get more data. What are good strategies to try and see if I'm outrunning the collector? Can I detect a low resource situation (for debug purposes only) and wait it out a bit and see if the collector catches up? (how?) What's the best way to find large malloc allocations that doesn't involve instruments collapsing under the load of data? (it can take 10 minutes or more to reach the failure point). All pointers appreciated. ___ 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]
NSTextFieldCell subclass template image inversion
Hello list My NSTextFieldCell subclass is based on ImageAndTextCell.m from the SourceView sample. This displays text and images in a single cell. My difficult is in getting system media template images to invert when the cell is highlighted. The documentation for NSImage - setTemplate states: You can mark an image as a “template image” to notify clients who care that the image contains only black and clear content. Yes, I detect that an image is a template, but how do I initiate caring. My feeble attempts at getting my client to care have firstly been to try and invert the NSImageRep of the template, but this fails as the image rep is the undocumented NSCoreUIImageRep and not a NSBitmapImageRep. My second attempt was along the following lines: [cell setHighlighted:YES]; [cell setState:NSOnState]; NSImage *image = [cell preparedImage]; A modified - duller - image is returned, but not an inverted one. I think that this is more along the right track. But something's missing (brains probably). Any enlightenment would be welcome. Jonathan ___ 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: What's the NSMailDelivery replacement for Leopard and Beyond?
for simple email, i've used +[NSURL URLWithString:] to create a mailto: url: mailto://[EMAIL PROTECTED] and then open the url. u can also add parameters such as subject and body but i forget the details at the moment (i think its something like ?subject=...) 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]
core data: awakeFromFetch, awakeFromInsert, didTurnIntoFault
in a couple of my classes subclassed from NSManagedObject, i provide the methods: awakeFromFetch, awakeFromInsert, didTurnIntoFault. in the awake messages, after calling the appropriate super methods, i establish some observers like: [[NSNotificationCenter defaultCenter] addObserver: self ...]; and in the didTurnIntoFault method, i remove myself as an observer. i just noticed that if i create a new one of these entities and then undo it, the sequence of events is as expected: awakeFromInsert didTurnIntoFault however, if i then redo the action, neither awakeFromFetch nor awakeFromInsert is called, and thus i'm left without my observing in place. should i be handling this some other way? if so, how? (pointers to documentation would be sufficient). if this is the proper approach, how do i re-establish my observing? th;anx, 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: Set view in bottom right corner of NSTableView
The PlacardScrollView subclass at http://cocoa.karelia.com/AppKit_Classes/PlacardScrollView__.m demonstrates this technique well. On 16 May 2008, at 18:15, Kyle Sluder wrote: On Fri, May 16, 2008 at 10:49 AM, Stéphane [EMAIL PROTECTED] wrote: This might not be that easily possible as the positions of the views inside the scrollview are recomputed quite often and your bottom corner view would be ignored by this code. So this would require subclassing some code in NSScrollView. Not impossible but not easy and this part of the AppKit does not work the same way between OS versions. Actually, it's not that hard. Subclass NSScrollView and override - tile. --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: NSDictionaryController with NSTableView and sorting of numeric data
Thanks For the reply Kyle On 16 May 2008, at 06:43, Kyle Sluder wrote: On Thu, May 15, 2008 at 5:30 PM, [EMAIL PROTECTED] wrote: It would seem that NSDictionaryController keys have to be strings. Yes. It is very common that, despite NSDictionary accepting any object as a key, you must use NSString keys. So the sorting of numeric string keys is always going to be alphabetic. Not true. See -[NSString compare:options:] with the NSNumericSearch option. Good to be directed towards this method. I had missed the NSNumericSearch option. My solution was to discard NSDictionaryController and create a proxy object containing two properties: I would instead suggest subclassing NSDictionaryController and overriding -arrangedObjects. The naive implementation would call super's implementation and return a sorted version of the result. The published interface says that -arrangedObjects returns id, but the documentation says that it returns an array, so I would feel reasonably safe treating the return value as an NSArray. That's a much more classy solution than my proxy object array kludge. --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: NSDictionaryController with NSTableView and sorting of numeric data
Thanks for the reply Shawn One of the big attractions of the bindings technology is that the sorting behaviour is automatic and normally pretty satisfactory. But I agree that in this case manually manipulating the sort descriptors could be a good solution. Jonathan On 16 May 2008, at 07:05, Shawn Erickson wrote: Consider using the built in sort facility... http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSArrayController/setSortDescriptors: http://developer.apple.com/documentation/Cocoa/Conceptual/SortDescriptors/Concepts/Creating.html -Shawn ___ 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]
Set view in bottom right corner of NSTableView
Hello List I have been using NSTableView -setCornerView: to provide additional drag thumb image views for tables embedded in splitviews. Has anyone found it possible to do the same thing in the bottom right hand corner of a table as opposed to the top? Obviously there is no NSTableView -setBottomCornerView: method but I thought it might be possible by manually adding a subview to the enclosing NSScrollView. Any help would be appreciated. Jonathan ___ 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: Set view in bottom right corner of NSTableView
Once again Kyle, thanks. This looks like just the ticket. On 16 May 2008, at 18:15, Kyle Sluder wrote: On Fri, May 16, 2008 at 10:49 AM, Stéphane [EMAIL PROTECTED] wrote: This might not be that easily possible as the positions of the views inside the scrollview are recomputed quite often and your bottom corner view would be ignored by this code. So this would require subclassing some code in NSScrollView. Not impossible but not easy and this part of the AppKit does not work the same way between OS versions. Actually, it's not that hard. Subclass NSScrollView and override - tile. --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]
NSDictionaryController with NSTableView and sorting of numeric data
Hello list I have bound an NSDictionaryController to an NSTableView. The keys in my bound dictionary are numeric strings 1... n The dictionary keys and values display okay but the sorting of the key column is not numeric but alphabetic. The value column sorts fine for objects of type NSNumber. I have tried using NSNumber keys and an NSValueTransformer subclass but the controller seems to need an NSString key. I know I am being dumb here. Please put me out of my misery. Thanks Jonathan ___ 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]
command-period doesn't close NSComboBox popup window
by subclassing NSComboBox and providing a subclass of NSTextView as its field editor, i am able to support the home/end/page down/page up keys in the popped up window. (i'm surprised this isn't the default behavior!) however, i haven't been able to figure out how to support command-period (to be equivalent to the escape key and i'm even more surprised that this doesn't just work). any suggestions? ken ps to avoid any/lots of requests for code, here is what i do. my field editor overrides/provides methods for scrollPageDown, scrollPageUp, scrollToEndOfDocument, scrollToBeginningOfDocument and passes this on to its delegate--my NSComboBox subclass. MyComboBox keeps track of whether or not the popup window (by using the appropriate notifications) is up, and if so acts accordingly. all very straight-forward. ___ 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: Check box cell in NSTableView
I recently put together a sequence of interlinked NSTableViews using checkbox cells. It displays the mixed state without problem. So no bug I think. I used a datasource in this case, as below. - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { // for the checkbox column if ([scriptHandler count] == [scriptHandler publishedCount]) { state = NSOnState; } else if ([scriptHandler publishedCount] 0) { state = NSMixedState; } else { state = NSOffState; } return [NSNumber numberWithInt:state]; } It doesn't matter if I do the [myCheckBox setState:NSMixedState]; the result is the same, the checkbox is shown as checked. If I however use the same code (or even click all the three states) in an ordinary check box (not cell), everything works as I expect it to do. This makes me suspect this to be a bug. Ivan Den 11. mars. 2008 kl. 14:42 skrev Stephane Sudre: On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote: I can not get my check boxes in an NSTableColumn to show the mixed state. The first time I click an empty check box, it shows as if it is checked, it should have been mixed. A mixed state can not be determined by a click. What a click should do: Unchecked - Checked Mixed - Checked Checked - Unchecked ___ 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]
Detecting resolution changes?
I want to detect when a screen's resolution has changed, so I can resize and re-center my main window. Does NSWindowDidChangeScreenProfileNotification do what i want? If the user moves the window (into a differently-sized widow, causing a change), it looks like I could trap/check at NSWindowDidChangeScreenNotification. What I wasn't clear about is whether a screen's profile included the resolution. Thanks, Mark ___ 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: Intel mac required for iPhone development
I'm just curious but why? Well, since various Apple people have already pointed out discussing the iPhone SDK is part of an NDA, so there's no way you'll get an answer. I'm sure it revolves around the fact that limiting the sw and hw supported reduces the development effort for that team, but we'll never know exactly… Mark___ 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]