-[NSURLCredentialStorage removeCredential:forProtectionSpace:] broken?
Is there a known problem with -[NSURLCredentialStorage removeCredential:forProtectionSpace:], or are my expectations wrong? I iterate all the credials in the storage looking for the one I wish to remove, then send -removeCredential:forProtectionSpace: to the instance, and it doesn't actually remove the item from the keychain. Is this supposed to work? (Yes, I know I can, and probably will have to, drop down to the keychain APIs directly.) —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: adding something to a setter
Do not use self as your observation context. Your observation context has to be unique for all observers of the object. “self” is a bad choice. Also, you should only do your own work in the case that the observer is your observer. In the code below, you are also doing your work in the case where you should only be calling through to super. —Jim On Oct 6, 2011, at 5:47 AM, Stephan Michels wrote: I use KVO to execute custom code if a property has changed. [self addObserver:self forKeyPath:@graphics options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:self]; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (context != self) { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } if ([keyPath isEqualToString:@graphics]) { [self setNeedsDisplay:YES]; } } AFAIK the observe method will not be executed instantaneously, but on the other side setNeedsDisplay has also a deferred execution. Stephan. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data : Undo Delete : Cannot fulfill a fault
On Sep 30, 2011, at 12:06 AM, Quincey Morris wrote: The actual failure scenario I described has 2 necessary conditions. One is a save boundary. The other is the flushing of cached property information for the deleted object. The latter is difficult to cause, especially in a trivial example, since there's no API for affecting the cache directly, except for resetting the MOC, which would probably break undo for different reasons. I guess the question here is this: If it's true that deleting a managed object causes it to be turned into a fault at some point (at the next save boundary at the latest), and saving a managed context with a deleted object actually causes the object's persistent representation to be deleted from the persistent store, and post-save the object is still referenced by an undo action, what possible mechanism can re-populate the object's properties if the undo action is undone? By definition, the necessary information no longer exists. You are assuming that the only place this information can exist is in the row cache itself. The information can exist anywhere. At the risk of over-trivializing the problem—It’s just code™. All the information necessary to resurrect the object (or restore properties) can be stored on the undo stack itself. —Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data : Undo Delete : Cannot fulfill a fault
On Sep 30, 2011, at 5:41 AM, Jerry Krinock wrote: I'm still working on this issue, trying to find the trigger which moves my corner case into the corner, hoping for a workaround. It's tedious because of different operations and states. But you have a pretty reliable way to reproduce the bug, right? Have you taken my previous advice? Have you broken at the point of objc_exception_throw for the NSObjectInaccessibleException and examined what, specifically, is firing the fault? Start here and work backwards and you may be able to infer why someone has a reference to a stale object. At the very least you’ll know who. (You’ve already got the type and ID of the stale object.) The implication of the last two points is that Core Data implements Undo quite on its own; the undo manager acts as little more than a counter. I'm not sure how you jumped to this conclusion. Core Data is recording invocations in NSUndoManager in much the same way you'd do if you were using NSUndoManager directly. —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data : Undo Delete : Cannot fulfill a fault
On Sep 29, 2011, at 11:20 AM, Quincey Morris wrote: I think the answer to your original question is that You're Doing It Wrong™. :) I'm pretty sure (though I never really thought about it before today) that Core Data undo *doesn't* work across 'save:' boundaries. The documentation for [NSManagedObjectContext undo:] says this: Sends an undo message to the receiver’s undo manager, asking it to reverse the latest uncommitted changes applied to objects in the object graph. Note that word uncommitted. After 'save:', all changes are committed, so you're not permitted to undo past that point. At least, that's how I read it. That documentation is unfortunately confusing. Someone should file a bug to have it clarified. Core Data’s undo stack does allow you to undo past the last save point. And if it didn’t, it would remove actions from the undo manager, resulting in a disabled undo menu, not leave a bunch of actions on the undo stack that would generate exceptions if the user had the nerve to actually keep undoing past the last save point. If I'm right, you should be clearing the undo stack at a save, at least if there are deleted objects in the picture. If you in fact had to do this, this would be a pretty grievous bug. If the MOC registers actions with its undo manager that it can no longer deal with, it should be the one who removes them or clears the stack. A trivial NSPersistentDocument sample application handles undo correctly across save boundaries for both property changes and deletes. Jerry Krinock wrote: It's always the same exceptional object which whose deletion is unable to be undone because Core Data could not fulfill a fault. Its parent is an object that was not deleted and therefore does not need to be restored. It has one child which has already been successfully restored at the time the exception occurs. Have you broken at the point of objc_exception_throw for the NSObjectInaccessibleException and examined what, specifically, is firing the fault? Start here and work backwards and you may be able to infer why someone has a reference to a stale object. At the very least you’ll know who. (You’ve already got the type and ID of the stale object.) If you can isolate this into a standalone sample, (and in the process haven’t found a bug in your code causing it) you can file a radar and post a link to the sample here and maybe we can offer further advice. —Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: confused by what seems to be a recursive declaration/definition
On Aug 11, 2011, at 7:27 PM, William Squires wrote: On Aug 11, 2011, at 6:51 PM, Kyle Sluder wrote: On Thu, Aug 11, 2011 at 4:26 PM, Jens Alfke j...@mooseyard.com wrote: On Aug 11, 2011, at 4:10 PM, Luther Baker wrote: static void *AVPlayerDemoPlaybackViewControllerRateObservationContext = AVPlayerDemoPlaybackViewControllerRateObservationContext; It’s initializing the variable to point to itself. Which seems sort of pointless, but I don’t know the context. It's a quick way to initialize a unique pointer when you don't care about the value. Of course, if you don't care about the value, why would you need a unique one? :) For KVO contexts, you don't care about the value, but you do care that it is unique. —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using Multi-Gesture events with Carbon
On Jun 29, 2011, at 2:24 PM, Abdul Sowayan wrote: I have a carbon based application that we are converting overtime to Cocoa. What I would like to do, if possible, is to incorporate multi-gesture events (such as magnify event) into my carbon application. I can see that NSResponder has magnifyWithEvent: selector. I am wondering if there is anyway to do so. Any feedback on how to do so would be greatly appreciated. Magnify, swipe, and rotate are available as Carbon Events. —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TransformProcessType() still doesn't show menu (Bug ID# 5905139)
On May 26, 2011, at 7:21 PM, Jerry Krinock wrote: I just thought I'd lift my head up long to say thank you, Anders. Unfortunately, your code doesn't work in my app. Tried several mutations; still no good. Another thing I learned is that programmatically switching apps, simulating the user typing cmd-tab, which works when the user does it, does not work when the program does it. I hard-coded pids of several running programs, activated each for 1 second, then activated my app. Looked very impressive until it got to my app, and the menu bar continued to show the previously-activated app. This is an unfortunate bug, but you should be able to work around it with this sequence: [[NSApplication sharedApplication] hide: nil]; ProcessSerialNumber psn = {0, kCurrentProcess}; verify_noerr(TransformProcessType(psn, kProcessTransformToForegroundApplication)); [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -[NSSet containsObject:] returns NO when it should return YES
On Feb 19, 2011, at 2:17 PM, Michael Crawford wrote: I'm trying to compare instances of NSNumber using NSSet. I have a set of numbers, which represent 64-bit persistent IDs for iTunes media-items. I access these values using the -[NSNumber longLongValue] method. I'm adding them to an instance of NSSet and then use that instance to determine whether or not I've seen the given item before. Anyone have previous experience with this problem? Can you shed some light on where my thinking and assumptions are wrong. The documentation for -[NSSet containsObject:] says: Return Value — YES if anObject is present in the set, otherwise NO. The documentation for -[NSSet member:] says: Return Value — If the set contains an object equal to object (as determined by isEqual:) then that object (typically this will be object), otherwise nil. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Return key should enter return in textfield and not press default button
On Oct 11, 2010, at 2:21 AM, Thorsten Lemke wrote: I have a dialog in my app wich should let the user enter a carriage return. How can I avoid pressing the default button with return? Only enter should press it in this case. As you probably know, implementing this will be hugely popular with people who understand how it works, and confusing to everyone else. That said… For your edit field implement - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector; When the command selector is insertNewline:, act accordingly based on the current event. —Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending a Cmd-V keystroke
On Mar 25, 2010, at 8:23 PM, Jim Graham wrote: This is a problem that occurred a few months back in a project. I Never actually used it in the project but it has bugged me ever since. I have simplified the problem into a small example There is a window with three NSTextFields and a button. The button is connected to the doPaste action and the fields are outlets Before explaining why your code, as written doesn’t work, and how to fix it, can you give some background as to why you are doing it this way? Unless you are trying to write a tool similar to Keyboard Maestro, you probably don’t want to be doing it this way. - In general, you probably want to modify the model objects programmatically, and have the views react and update their display values. - In the case that you want to update the views directly, you really ought to be reading the value from the pasteboard and setting the view’s display value programatically. If this really is an academic exercise in pulling puppet strings on the UI, and you have legitimate reasons for doing so, including them in the original question would have avoided the speculation about why you are doing something which seems superficially crazy. Problem #1: Here is the code -(IBAction)doPaste:(id)sender{ NSPasteboard *pb = [NSPasteboard generalPasteboard]; [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; [pb setString:@Field 1 forType:NSStringPboardType]; [textField1 becomeFirstResponder]; [self pasteIt]; [pb setString:@Field 2 forType:NSStringPboardType]; [textField2 becomeFirstResponder]; [self pasteIt]; [pb setString:@Field 3 forType:NSStringPboardType]; [textField3 becomeFirstResponder]; [self pasteIt]; } -(void)pasteIt{ CGEventSourceRef sourceRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); if (!sourceRef) { NSLog(@No event source); return; } //9 = v CGEventRef eventDown = CGEventCreateKeyboardEvent(sourceRef, (CGKeyCode)9, true); CGEventSetFlags(eventDown, kCGEventFlagMaskCommand); CGEventRef eventUp = CGEventCreateKeyboardEvent(sourceRef, (CGKeyCode)9, false); CGEventPost(kCGHIDEventTap, eventDown); CGEventPost(kCGHIDEventTap, eventUp); CFRelease(eventDown); CFRelease(eventUp); CFRelease(sourceRef); } I expected that each of the fields would have their respective text pasted into them. What actually happens is that the last field gets three copies of it's text, Field 3, pasted into it. The other two fields are blank. Can anybody explain why that should happen. Jim Graham___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jim.correia%40pobox.com This email sent to jim.corr...@pobox.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending a Cmd-V keystroke
On Mar 25, 2010, at 8:23 PM, Jim Graham wrote: This is a problem that occurred a few months back in a project. I Never actually used it in the project but it has bugged me ever since. I have simplified the problem into a small example There is a window with three NSTextFields and a button. The button is connected to the doPaste action and the fields are outlets Before explaining why your code, as written doesn’t work, and how to fix it, can you give some background as to why you are doing it this way? Unless you are trying to write a tool similar to Keyboard Maestro, you probably don’t want to be doing it this way. - In general, you probably want to modify the model objects programmatically, and have the views react and update their display values. - In the case that you want to update the views directly, you really ought to be reading the value from the pasteboard and setting the view’s display value programatically. If this really is an academic exercise in pulling puppet strings on the UI, and you have legitimate reasons for doing so, including them in the original question would have avoided the speculation about why you are doing something which seems superficially crazy. [pb setString:@Field 1 forType:NSStringPboardType]; [textField1 becomeFirstResponder]; Problem #1: You change the first responder to sending -makeFirstResponder: to the window. It may fail if editing could not be committed for he current editor. -(void)pasteIt Problem #2a: This code assumes that your window is the key window and the application is frontmost. Problem #2b: You have posted an event, but until AppKit dequeues the event and processes it, the paste doesn’t actually happen. This is why you eventually get 3 pastes in the last edit field. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data: fetching a subset of attributes/columns
On Mar 20, 2010, at 1:52 PM, Gabriel Fernandez wrote: I wanted to get a subset of an entity's attributes because one of the ManagedObject's attributes is a large image. […] 2) using the -setPropertiesToFetch: method of NSFetchRequest, with the id NSAttributeDescription I'm looking for as the only object in the properties array. But when I use the -(NSArray*) properties method of the fetched objects, the image attribute is there with a non-nil value. Read the API documentation, or the header comment for this method. /* Specifies a collection NSPropertyDescriptions that should be returned by the result. This value is only used if resultType is set to NSDictionaryResultType. Property descriptions added to valuesToFetch may represent attributes, expressions, or to one relationships; for attribute or relationship descriptions, the name must match the name of a description on the fetch entity. Results of the fetch will be returned as dictionaries containing key/value pairs where the key is the name of the specified property description. */ — Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSComboBox problem in 10.6.2
On Mar 18, 2010, at 3:38 PM, H. Miersch wrote: when i try to launch the app from within xcode, the console shows the following: 2010-03-18 19:26:28.515 StoX[63999:a0f] An uncaught exception was raised 2010-03-18 19:26:28.534 StoX[63999:a0f] *** -[NSCFArray objectAtIndex:]: index (-1 (or possibly larger)) beyond bounds (5) 2010-03-18 19:26:28.596 StoX[63999:a0f] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (-1 (or possibly larger)) beyond bounds (5)' *** Call stack at first throw: ( 0 CoreFoundation 0x7fff87ddb444 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x7fff800470f3 objc_exception_throw + 45 2 CoreFoundation 0x7fff87ddb267 +[NSException raise:format:arguments:] + 103 3 CoreFoundation 0x7fff87ddb1f4 +[NSException raise:format:] + 148 4 Foundation 0x7fff8798e080 _NSArrayRaiseBoundException + 122 5 Foundation 0x7fff878f0b81 -[NSCFArray objectAtIndex:] + 75 6 AppKit 0x7fff80ba2012 -[NSComboBoxCell selectItemAtIndex:] + 191 7 StoX0x00011693 -[AppController awakeFromNib] + 50 This is the interesting frame 8 CoreFoundation 0x7fff87d8a82d -[NSSet makeObjectsPerformSelector:] + 205 9 AppKit 0x7fff8086c913 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1445 10 AppKit 0x7fff8086ab49 loadNib + 226 11 AppKit 0x7fff8086a059 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248 12 AppKit 0x7fff80869e91 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326 13 AppKit 0x7fff80867413 NSApplicationMain + 279 14 StoX0x000115a8 start + 52 ) terminate called after throwing an instance of 'NSException' i've checked that i'm using the types that the docs say i should be using, but i don't understand why index comes back as -1. am i doing something wrong? should I be doing something i'm not doing? is the documentation wrong? is there a bug somewhere? Look at your code in awakeFromNib. It appears you are ending -selectItemAtIndex: to the combo box, and the index is out of bounds. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSComboBox problem in 10.6.2
On Mar 19, 2010, at 3:21 PM, H. Miersch wrote: just had another surprise: i inserted NSLogs into the method that initializes the array and into -numberOfItemsInComboBox, trying to see the contents of my array and find out why -numberOfItemsInComboBox returns zero. the surprise was that -numberOfItemsInComboBox is called BEFORE the method that initializes the array. then i commented the line that sends -selectItemAtIndex to the combobox, and the combobox worked normally. now the question is, why is -numberOfItemsInComboBox called first when the first call in awakeFromNib is to the initialisation method? weird... -awakeFromNib { init array; [combobox selectItemAtIndex:0]; // if this line is turned into a comment, it works normally. [combobox2 selectItemAtIndex:2]; [combobox3 selectItemAtIndex:0]; register for notifications from combobox; } You are setting up your array in your -awakeFromNib. You cannot control (or know) the order in which -awakeFromNib will be sent to objects in your nib. The combo box may be awoken long before you. But more to the point, your contract with the combo box as its data source is that you will send it -noteNumberOfItemsChanged or -reloadData whenever you change the data in the data source. You became the data source for the combo box during nib unarchiving, changed the number of items in the model after nib unarchiving, and didn’t inform the combo box about that change. Sending the combo box the appropriate method after initializing your data source should fix the problem. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: File Backup Date
On Mar 16, 2010, at 12:09 PM, gMail.com wrote: Anyway, I have noticed that if in the Finder (MacOS X 10.6.2) I open a file which contains a backup date, then I modify the content and I save it, the backup date disappears. What are you using to modify the content of the file? Consider the possible ways this could be implemented: a) application updates the file in place b) application writes an entirely new file, then swaps it in place of the original file. In case (b) the application may or may not preserve metadata on the original file. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Making a beta version expire
On Mar 11, 2010, at 11:03 PM, Ulai Beekam wrote: Do you think this would work? I mean, it seems that it should, but one can never be sure Why can’t you be sure? After reading your algorithm and convincing yourself that the code is correct, step through it in the debugger with expirations dates both in the past and the future. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data: inverse relationship not updated until next Run Loop
On Mar 11, 2010, at 8:11 PM, Eric Lin wrote: In using Core Data, I was under the impression that if I do this: [department addEmployeesObject:employee] // department now has 1 employee [moc deleteObject:employee] Then department will end up with no employees, assuming that the inverse relationship is set correctly. But it turns out within the same run loop, if I inspect [department.employees count], then the value is 1. But in the next run loop, the value becomes 0, which is what it should be. Is my observation accurate or is something wrong? Deletes are propagated at the end of he current event, or at save time, depending how the MOC is configured. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSServices - Validation bug
On Mar 8, 2010, at 5:02 AM, tr...@atheeva.com wrote: I have some queries regarding Services menu validation . I would like to enable different services provided by my app based on whether a file or folder is selected in the Finder. I have set NSFilenamesPboardType as the send type for the services.I have gone through the - (id) validRequestorForSendType:(NSString*)sendType returnType:(NSString *)returnType method but my issue is that the validation there seems to be done based on the sendType and return type. In my case , the selected file and folder pasteboard type is the same and I cannot determine whether the selected item in the Finder is a file or folder during the validation process(This is before the actual service gets invoked i.e when the services menu is being shown to the user )? So my question is that is there any way I can get some info about the selected item in the Finder and validate the different service menus offered by my application based on some info regarding the item rather than the basic validation of the send and return types ? You can only validate by the type in your service validation method, not the contents of the pasteboard. You can switch to using more specific UTIs for our service (if you only, for example, want to accept a file, folder, or package). You can also use NSRequiredContext in your service specification to restrict service availability based on pasteboard content. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using Core Data in Command Line utility
On Mar 8, 2010, at 8:44 PM, Paul Johnson wrote: The problem I'm having is the line that tries to store the integer: [object setValue:i forKey:@fileIndex]; I get the compiler error Passing argument 1 of 'setValueforKey' makes pointer from integer without a cast”. -setValue:forKey: takes an object for the value parameter. You have to pass an object - in this case our integer boxed in an NSNumber object. Can anyone tell me how to fix this? I'm also wondering if I'm using the correct methods to accomplish the task. You should also take a look Core Data’s dynamically generated accessor methods. These are typically what you should be using to set and access properties on your managed objects. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindow - how to resize it keeping aspect ratio?
On Feb 18, 2010, at 1:55 PM, Alexander Bokovikov wrote: I'm sorry if this is a stupid question, but I don't see an evident answer... I need the subj, but don't see appropriate NSWindow method... Am I missing something? -[NSWindow setAspectRatio:] -[NSWindow setContentAspectRatio:] - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: “EXC_BAD_ACCESS” on Custom TableV iew with custom NSCell when clicking.
On Feb 17, 2010, at 4:41 PM, Gustavo Pizano wrote: Maybe I misunderstood I must conform NSCopying protocol also even when using core data? If you have an NSCell subclass which adds iVars, you must implement -copyWithZone: to do correct memory management. Your -copyWithZone: needs to work correctly within the bounds of the object ownership rules. If you have an object iVar which shouldn’t be copied, but is still an owned reference, then you can (and must) retain it instead in the copy. (You should do this for all cells with iVars, not just ones with object iVars, so that your subclass will behave correctly in the future even if NSCell doesn’t implement its behavior using NSCopyObject.) - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Typo in notification name
On Mon, Jan 18, 2010 at 4:20 AM, Mark Munz unmar...@gmail.com wrote: Apple usually addresses binary compatibility by changing behavior if you link against a newer major SDK. So a behavior changes if you link against 10.6 vs. 10.5. Apple has done this numerous times. With notifications, they could also send out both notifications. I'm thinking com.apple.loginItemsListDidChange doesn't happen often enough to cause a performance hit if you sent out both each time. The other thing to consider is that if you are observing a public notification, you should use the symbolic constant for that notification when it is available. In that case, the underlying value doesn't matter. The public API for interacting with, and observing, the login items list is LSSharedFileList. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Managed Object with Getter
On Jan 13, 2010, at 8:39 AM, Richard Somers wrote: On Jan 13, 2010, at 1:17 AM, Kyle Sluder wrote: This code cannot generate that error because it doesn't send any messages. You need to post the code to which the error actually refers. This works. @property (nonatomic, retain) NSNumber *selected; if ([[self selected] boolValue]) { ... } This produces error unrecognized selector sent to instance. @property (nonatomic, retain, getter=isSelected) NSNumber *selected; if ([[self isSelected] boolValue]) { … } Assuming you are using @dynamic and relying on Core Data to generate the accessors for you, that isn’t going to work. Core Data doesn’t support the isPropertyName getter style. This style is typically used for non-object BOOL values. If you use it for an NSNumber attribute, you run the risk of someone familiar with the pattern assuming it is a BOOL property and writing if ([managedObject isSelected]) { } which will of course be be true whenever the property is non-nil, no regardless of the actual value. If you want or need to use custom getters/setters, you’ll have to provide your own accessors rather than relying on the @dynamic generated ones. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Managed Object with Getter
On Jan 13, 2010, at 7:29 PM, Richard Somers wrote: On Jan 13, 2010, at 7:14 AM, Jim Correia wrote: This style is typically used for non-object BOOL values. If you use it for an NSNumber attribute, you run the risk of someone familiar with the pattern assuming it is a BOOL property and writing if ([managedObject isSelected]) { } which will of course be be true whenever the property is non-nil, no regardless of the actual value. Thanks for the reply and the information. The attribute is a bool in the Xcode data modeler. When you copy the Obj-C 2.0 method declarations for the bool attribute to the clipboard this is what you get. @property (nonatomic, retain) NSNumber *selected; So I assume that Core Data frameworks default is to use a NSNumber for a bool value. That is correct. Core Data always expresses its attribute as object values. If you want to have a scalar BOOL property on your object, you can, but you must write your own accessors. (And be aware of and deal with -setNilValueForKey: as appropriate.) For example: - (BOOL)isSelected { NSNumber *selected = nil; [self willAccessValueForKey: @selected]; selected = [self primitiveSelected]; [self didAccessValueForKey: @selected]; return (selected != nil) ? [selected boolValue] : NO; } - (void)setSelected:(BOOL)selected { [self willChangeValueForKey: @selected]; [self setPrimitiveSelected: [NSNumber numberWithBool: selected]]; [self didChangeValueForKey: @selected]; } - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Enabling NSZombieEnabled programatically
On Jan 9, 2010, at 6:22 PM, Sean McBride wrote: I've never tried, but NSDebug.h seems to say that there is an NSZombieEnabled global var that you can set. Read the warning at the top of the header. While those variables have been there as long as I can remember, as soon as you ship software which relies on them, Murphy will invoke his law. (For debug and pre-release builds, go wild. For production builds, take appropriate precautions.) - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Enabling NSZombieEnabled programatically
On Jan 9, 2010, at 7:54 PM, Graham Cox wrote: I'm getting something odd though. If I set NSZombieEnabled during app delegate -applicationDidFinishLaunching: method from my preference, a later deliberate over-release still causes a EXC_BAD_ACCESS. If I set it as an environment variable (Xcode launch arguments for my app) I get the zombie logged as expected. In either case I can see that NSZombieEnabled is YES, but directly setting it doesn't appear to work. Any idea what I'm doing wrong? Code: #include Foundation/NSDebug.h - (void) applicationDidFinishLaunching:(NSNotification*) aNotification The comment in NSDebug.h reads: This is mostly a benefit if you need to initialize these variables to some non-default value before your program's main() routine gets control” My guess is that -applicationDidFinishLauching: time is too late. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFilesPromisePboardType
On Jan 8, 2010, at 7:52 PM, Nick Paulson wrote: Can someone please explain to me how I handle NSFilesPromisePboardType? I register for the dragged types, but I don't understand exactly how to get the data. Did you read the documentation? http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DragandDrop/Tasks/DraggingFiles.html What part of the inline sample code are you having trouble understanding? NSURL *dropLocation; // Assume this exists - (BOOL)performDragOperation:(id NSDraggingInfo)sender { NSPasteboard *pboard = [sender draggingPasteboard]; if ( [[pboard types] containsObject:NSFilesPromisePboardType] ) { NSArray *filenames = [sender namesOfPromisedFilesDroppedAtDestination:dropLocation]; // Perform operation using the files’ names, but without the // files actually existing yet } return YES; } - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFilesPromisePboardType
On Jan 8, 2010, at 10:24 PM, Nick Paulson wrote: I am doing the following code: NSArray *filenames = [sender namesOfPromisedFilesDroppedAtDestination:[NSURL fileURLWithPath:@/]]; However, it is getting the following lines in console: Couldn't get a copy of an HFS Promise from the pasteboard Looked for HFSPromises on the pasteboard, but found none. I am dragging from iTunes in list view to my own view. Am I making a mistake somewhere? A couple of things to keep in mind here… * See the comment in the documentation about having to assume the files haven’t been created yet? You have to assume that, and it can complicate things. (I’ve logged a lengthy bug requesting ways to simplify file promise dragging, but the problem is complex because it requires system framework support *and* the cooperation of applications doing the dragging.) * You specified the drop location as /. Not all users have write permissions to the root of the disk, and it is unlikely that you really wanted iTunes to create the files here anyway. Ultimately, it appears that iTunes is putting bad promise data in the drag. At this point it is probably best to file a bug against iTunes. What is it you are actually trying to accomplish? Perhaps there is another solution. Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSFilesPromisePboardType
On Jan 8, 2010, at 11:33 PM, Jim Correia wrote: Ultimately, it appears that iTunes is putting bad promise data in the drag. At this point it is probably best to file a bug against iTunes. Looks like this might simply be a byte order bug with the value in the promisedFlavor field in the PromiseHFSFlavor data on the pasteboard (though that doesn’t really help when accessing the data via NSPasteboard.) On Jan 8, 2010, at 11:37 PM, Nick Paulson wrote: I am trying to get the path of an item dropped onto a view by iTunes. iTunes seems to only do this with NSFilesPromisePboardType. Maybe I am wrong, though. The promised data isn’t really what you wanted anyway. The idea behind the promise is that the drag provider *promises* to create a new file in location specified in the drag receiver. It sounds like you are interested in the file that is being dragged, not a copy of it. iTunes does provide all the data in the drag that you need (and more), but does so through the ‘itun’ drag flavor. I haven’t seen this documented anywhere as a public, supported pasteboard flavor. It has been available for some time, but unless it is documented as a such, it could disappear (or change) at any time. Proceed accordingly. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: duplicate method found, but can't locate
On Jan 6, 2010, at 7:33 PM, Shane wrote: I'm getting this error from my main app controller which is trying to send a message to a thread on a queue (using YAMessageQueue). [[networkQueue proxyForTarget:networkServer] save:[self saveFile]]; Cannot convert 'NSString*' to 'NSError**' in argument passing I have no idea where it thinks it needs to convert to NSError**. [self saveFile] returns an NSString*. In my server file I have the following: The problem is likely that -proxyForTarget: returns an `id`. I can see that there seems to be some confusion with the save: method in the @protocol because the warning seems to imply that it found 'another' save: by saying 'Also found …'. But I have no idea where it's finding the save: method that needs to use NSError**, if that is the case. NSManagedObjectContext defines -(BOOL)save:(NSError **)error; If -proxyForTarget: returns an id, then the compiler doesn’t know which of the available signatures you really meant to use. You can either rename your -save: method, or cast the result of -proxyForTarget to the static type you are sending the message to. - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why do bindings make my image disabled?
On Jan 1, 2010, at 5:39 PM, Michael Bishop wrote: What I have been able to figure out is that using bindings is somehow making my NSImageCell instances draw an image semi-transparently. I haven't been able to explain why this is but I'm hoping someone else has seen this. […] In the project you'll find an app delegate which has a status. There are some Image cells along the left that are bound to the status. They have different border types but are otherwise identical (copy and pasted). On the right, you'll see an image who is manually set by the delegate when its status is flipped. The only one that is faded out is the image that has no border and is bound. I can't for the life of me explain the faded image. Can anyone else? On 10.6, NSImageView will draw its content as dimmed when the control is disabled. Your binding has “Conditionally Sets Enabled” turned on. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reference NSSearchFieldCell within NSSearchField?
On Dec 29, 2009, at 3:02 PM, Mike Chambers wrote: The NSSearchField docs mention that it wraps an NSSearchFieldCell, which contains such APIs as setSendsWholeSearchString (which i need to dynamically set). Is there any programatic way to get a reference to the NSSearchFieldCell wrapped in a particular NSSearchField? I know I can link an IBOutlet to it directly in IB, but I would prefer just to use my existing outlet to the search field. NSSearchField inherits from NSControl. NSControl has a -cell method. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating CoreData classes
On Dec 27, 2009, at 11:52 PM, Brian Bruinewoud wrote: If I've generated core data classes from my model, how do I use them to create new values? Currently I'm doing this: CDClass *cdObject = (CDClass *)[ NSEntityDescription insertNewObjectForEntityForName: @CDClass inManagedObjectContext: context ]; This is in fact the correct idiom for doing this. But I'm looking for something more like this: CDClass *cdObject = [ CDClass insertNewObjectInManagedObjectContext: context ]; You can use CDClass *object = [[CDClass alloc] initWithEntity: entity insertIntoManagedObjectContext: context]; instead, but it is more verbose since you have to separately look up the entity by name. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSViewAnimationFadeInEffect broken in Snow Leopard?
On Tue, Dec 22, 2009 at 7:58 PM, Kevin Wojniak kain...@kainjow.com wrote: NSViewAnimationFadeInEffect doesn't seem to be working like it was in Leopard. I filed this as when SL was being seeded. If Regression: NSViewAnimation doesn't fade in view if initially hidden rdar://problem/7020352 If this affects you, you should also file a bug. The workaround is to show the view before running the animation. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data registered editors?
On Tue, Dec 22, 2009 at 9:33 PM, Rick Mann rm...@latencyzero.com wrote: I noticed that NSPersistentDocument's docs for isDocumentEdited talks about editors registered with the managed object context. Is there something that explains what a registered editor is? See the docs about NSEditorRegistration protocol: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSEditorRegistration_Protocol/Reference/Reference.html - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Are views active or inactive?
On Dec 22, 2009, at 10:45 PM, Rick Mann wrote: I'm listening for that notification. Sure is a clunky way to do things. I've never used a view framework that didn't tell views when they became active/inactive. AppKit views don’t have a native active/inactive status like carbon HIToolbox controls. For views which alter their appearance based on whether or not they are first responder, or in a key/main window, you must track this state yourself. I'm not sure viewDidMoveToWindow works here. I'm using it already for something else, and it gets called 3 times when my window is created, but never when activated. You can use viewWill/DidMoveToWindow to stop observing notifications on your preview window (if any) and start observing notifications on your new container window (if any), not for the tracking of the “active” state itself. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Detaching a thread to save a file?
On Fri, Dec 11, 2009 at 8:43 PM, Keith Blount keithblo...@yahoo.com wrote: Oops, sorry, forgot to ask: what happens if the user hits save again while the separate thread is already saving the search indexes to disk? Also consider what happens when the user hits save, then immediately quits before your file writing thread has finished writing the file to disk. (Since users generally get upset when you lose their data, you'll have to handle this case as well.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions
On Dec 4, 2009, at 1:52 PM, Grant Erickson wrote: I have implemented a custom class that derives from NSTextFieldCell to draw status for an associated device (not unlike the network source list in the Network System Preferences) overriding only: […] The issue I am having is determining the correct set of conditionals to use to determine when to invert the color of my text strings from backgroundColor (when the cell is selected and the associated table has focus) to textColor (when the cell is not selected or is selected and does not have focus). In general, the way to do this is to send -interiorBackgroundStyle to yourself, and pick a foreground text color suitable for the background. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions
On Dec 4, 2009, at 10:54 PM, Grant Erickson wrote: Thanks for the prompt reply. I forgot to mention one key element. The subclass must support 10.4- and later so I cannot rely on 10.5- and later APIs such as this. In that situation I’d probably write (and test!) if ([self respondsToSelector: @selector(interiorBackgroundStyle)]) { … compute text color from background style ... } else { … best effort text color calculation ... } Hopefully sometime soon the 10.4 branch can just go away. (If you have an existing product which already targets 10.4, changing the system requirements for something like this seems drastic. However, if you are developing a new product, you may want to seriously consider whether you really need to support Tiger, and the opportunity cost of doing so.) Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Behavior of CFStringUpper/Lowercase for NULL Locale?
The documentation for CFStringUppercase says: locale A CFLocale object that specifies a particular language or region. Prior to Mac OS X v10.3, this parameter was an untyped pointer and not used. The locale argument affects the case mapping algorithm. For example, for the Turkish locale, case-insensitive compare matches “I” to “ı” (Unicode code point U+0131, Latin Small Dotless I), not the normal “i” character. Prior to 10.3, the parameter was unused and NULL was always passed. The documentation doesn’t specify what the case mapping behavior is if NULL is passed for a locale. What is the behavior in that case? (Current locale? System locale?) - Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Dealing with faults in CoreData / AppleScript
On Nov 19, 2009, at 10:19 PM, Greg Hoover wrote: I've been working through adding scriptability to my CoreData application but ran into a snag: accessing relationships may return a fault instead of the actual set of objects. Is there an accepted way of solving this issue? I don't want the accessor to always fault the objects in, just when they're being accessed from AppleScript. Is creating another accessor the proper way to get around this? Can you be more specific about the problem you are having and what specifically you are trying to do? In particular, I’m not sure what you mean by: I don't want the accessor to always fault the objects in, ust when they’re being accessed from AppleScript. Unless you prefetch relationships, they will be a fault. (If you need to know, you can test this with -hasFaultForRelationshipNamed:. If you need to access the related objects though, you need to fire the fault. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about Style wrt private methods
On Nov 18, 2009, at 1:49 PM, Jens Alfke wrote: This is unfortunately true. The danger is that if you add an _- prefixed method to your class, it might conflict with a private method declared in a superclass. If this happens your method will override the internal one, and Really Bad Things will probably happen. It's a rare problem but it has happened before. (And even if everything works well now, any future OS update might add a new private method in a superclass that breaks your code. Again, this has actually happened.) This problem is just not restricted to private methods, or additions through categories. You can also run afoul of a namespace conflict with a public method in your subclass. Suppose you have a subclass of NSView which adds - reallyNiceMethodThatOughtToBeInAppKit. If Apple adds such a method in the next OS release, the same kinds of problem can result. (Similar problems when you extend delegate protocols for your subclasses too.) This problem is much less insidious than the category problem, but the potential does exist. (For both private and public methods.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about Style wrt private methods
On Nov 18, 2009, at 2:32 PM, Jens Alfke wrote: On Nov 18, 2009, at 11:15 AM, Jim Correia wrote: This problem is just not restricted to private methods, or additions through categories. You can also run afoul of a namespace conflict with a public method in your subclass. Yes; but this is less likely because Apple engineers add public methods less often (almost never in minor updates) and more carefully. Agreed. Subtle breakage is still possible across a major release when both you and Apple choose the obvious name for new functionality. -isHidden/-setHidden: on NSView is the sort of thing (which was added recently enough that many people likely remember it.) If you had subclassed NSView to add that functionality, its pretty likely you would have chose those names, or -isVisible/-setVisibible: because they are the obvious solution to the problem. You can avoid namespace clash altogether by writing ugly code, with names no one would ever want to use for your methods and properties. But who wants to do that? :-) Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Dependent/injected tests vs. linker visibility
[Moved from Xcode-Users since it really isn’t an Xcode issue.] I have some dependent/injected unit tests to test application-specific functionality. I've added a test that calls a C function which is defined in the application. This causes a link-time error because, by default, applications are compiled with -fvisibility=hidden. What practical solution are you all using for this problem? - Globally make symbols visible? - Only for Debug (or a Test specific) configuration? - Mark specific symbols, as required for the unit tests, to be visible? - Avoid using dependent/injected tests? Jim___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: removeObserver:forKeyPath: when already removed
On Nov 11, 2009, at 5:35 PM, James Walker wrote: I had a situation where removeObserver:forKeyPath: was called twice for the same receiver (an NSUserDefaultsController), the same observer, and the same key path. It threw an NSRangeException. But the KVO docs don't say anything about removeObserver:forKeyPath: throwing an exception. Should this be considered a documentation bug, or is it a bug that -[NSUserDefaultsController removeObserver:forKeyPath:] threw an exception, or should I have just expected this due to some general principle? Cocoa reserves the use of exceptions for programming errors an unexpected runtime errors. Trying to remove an observer for a key path which has already been removed (or never registered) falls into the programming error class, so I wouldn’t expect this to be explicitly documented. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatic Binding KVC KVO
On Nov 4, 2009, at 3:17 PM, Richard Somers wrote: @interface MyView : NSView { double num; } @end @implementation MyView - (double)num { return num; } - (void)setnum:(double)newNum { [self willChangeValueForKey:@num]; num = newNum; [self didChangeValueForKey:@num]; } @end When the view changes num, it need to push the change to the bound model objects. See mmalc’s Graphics Bindings sample: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Managed Object with Custom Data Caches
On Sat, Oct 31, 2009 at 12:05 PM, Richard Somers rsomers.li...@infowest.com wrote: The documentation states didTurnIntoFault method may be used to clear out custom data caches. So far so good. I was creating custom data caches in awakeFromFetch (or awakeFromInsert) until I realized that awakeFromFetch does not participate in undo. The documentation confirms that change processing is explicitly disabled around this method. So Apple provides a way to remove custom data caches associated with a managed object but no way to create them. Typically you set up the baseline value in -awakeFromFetch. Is there a specific reason you need this to be undoable? Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Managed Object with Custom Data Caches
On Oct 31, 2009, at 12:25 PM, Richard Somers wrote: On Oct 31, 2009, at 10:12 AM, Jim Correia wrote: Typically you set up the baseline value in -awakeFromFetch. Is there a specific reason you need this to be undoable? When the managed object is removed, didTurnIntoFault is called and the custom data caches are deleted. When the user does an undo on this action the managed object is fetched but awakeFromFetch is never called so the custom data caches are now missing. On 10.5 and earlier, you’ll have to re-create your data caches in an on-demand accessor. On 10.6 and later you can use -awakeFromSnapshotEvents: to re- establish them. Ji smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically invoking double-click bindings on NSTableView
On Wed, Oct 28, 2009 at 12:25 PM, Gerd Knops gerti-cocoa...@bitart.com wrote: Seems this should be easy: I have an NSTableView's Double Click Target, Double Click Argument, Double Click Argument2 etc. binding set, and they work fine. Now I would like to programmatically get the tableview to issue a double-click response. Obviously target and doubleAction are not useful in that context. Any ideas how to get this done? If this is just a one-off case, the simplest solution is to invoke the method with the appropriate arguments on the target directly. If you are looking for a more general solution, you can retrieve the binding data from the table view using -infoForBinding:, valuate the target arguments, and invoke the method that way. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: keyPathsForValuesAffectingValueForkey: not updating immediately
On Tue, Oct 27, 2009 at 11:39 AM, Brad Gibbs bradgi...@mac.com wrote: I don't think there's anything wrong with the method -- I've used it successfully in other apps and have seen it work in Apple sample apps, it just isn't working in this particular case. I'm sure that there's something wrong on my end. Just looking for a little help in figuring out what that could be... We are at the point where we can't offer useful advice without seeing your code. Since +keyPathsForValuesAffectingKey is not fundamentally broken, the most likely cause is a problem with your code. - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:self.streetAddress, self.city, self.state, self.zipCode, nil]; } This is wrong for 2 reasons. Reason #1 - see below. Reason #2 - you should be passing the literal key paths which affect the value, not self.streetAddress which is the current value of that key path. I've also tried: - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:@streetAddress, @city, @state, @zipCode, nil]; } +keyPathsForValuesAffectingKey should be implemented as a class method. (That's what the + prefix means.) You've implemented it as an instance method. Change it to a class method and you should find that it works correctly. (If you set a breakpoint on your code as written, you'll find that it is never called, which should be a warning sign to you that something is wrong.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: keyPathsForValuesAffectingValueForkey: not updating immediately
On Mon, Oct 26, 2009 at 10:03 PM, Brad Gibbs bradgi...@mac.com wrote: I did read the documentation, which is why I used +keyPathsForValuesAffectingFullAddress. I also tried +keyPathsForValuesAffectingValueForFullAddress: Both methods work, but only after changing the view and then coming back to it. +keyPathsForValuesAffectingKey is not fundamentally broken - I use it on my NSManagedObject subclasses as needs dictate. At this point, I think we need more information to help. At the very least, let's see your implementation of + keyPathsForValuesAffectingFullAddress. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Trying to understand -awakeFromNib problem
On Oct 25, 2009, at 7:53 AM, Graham Cox wrote: Then, running on 10.5.(8) I stared to get an error that the object new class derived from new base class did not respond to - awakeFromNib. I'd not previously seen this error until I refactored my code. Sure enough my new base class and its new fork don't implement awakeFromNib because they don't need to. On 10.6 there is no error. On 10.5.8 I get the error, suggesting that 10.6 first checks whether -awakeFromNib is implemented and 10.5 does not. Do your controller subclasses send [super awakeFromNib]? NSObject implements -awakeFromNib on 10.6 and later (but not previously.) - Jim smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Trying to understand -awakeFromNib problem
On Oct 25, 2009, at 12:22 PM, Roland King wrote: Where's that documented??? I looked for that when I saw the original question. For iPhone it's documented under NSObject UIKit Additions Reference, for 10.6 it's under NSNibAwakingProtocol which doesn't show up anywhere as an implemented protocol of NSObject. I'm sure you're right but I've tried every search I can reasonably think of in the documentation and I can't find it. See the Snow Leopard AppKit release notes. - Jim smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Preserving camelCase when prefixing a method name?
On Oct 13, 2009, at 10:24 AM, Graham Cox wrote: I think just making the first character uppercase would be sufficient, but I'm not sure how to do that reliably with the unichar data type, so that's my first question. Well you don't have to consider all of unicode, just those characters which are valid language identifiers. Nonetheless, applying -uppercaseString to the first character should solve the problem. The second is that when generating selectors programmatically like this, are there other pitfalls to consider so that the resulting selector is always predictable? The scheme needs to work with arbitrary properties, just as various parts of KVC and KVO do. Don't forget to account for the pattern often used for BOOL 'properties'. (I put properties in air quotes because actual properties allow you to specify the getter and setter name.) -isFlagged -setFlagged: - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [UTI] Anyway to retrieve the UTI of a file without having to use a FSRef?
On Mon, Oct 12, 2009 at 6:36 PM, Iceberg-Dev dev.iceb...@gmail.com wrote: From what I've found in the documentation, the UTI type of a file can be retrieved using the LaunchServices APIs. This requires to provide a FSRef. Wouldn't there be an API I didn't see in Foundation that lets you obtain the type without having to convert, at least, a NSURL to a FSRef? See, on NSWorkspace: - (NSString *)typeOfFile:(NSString *)absoluteFilePath error:(NSError **)outError; - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSAttributedString always returns NO for -isEqualToAttributedString with attachments present?
The documentation for -[NSAttributedString isEqualToAttributedString:] says: Attributed strings must match in both characters and attributes to be equal. It doesn't mention attachments at all. Consider the following code: attributedString is the input string, and it may contain image attachments NSData *d = [NSKeyedArchiver archivedDataWithRootObject: attributedString]; NSAttributedString *s1 = [NSKeyedUnarchiver unarchiveObjectWithData: d]; NSAttributedString *s2 = [NSKeyedUnarchiver unarchiveObjectWithData: d]; NSLog(@isEqual = %d, [s1 isEqualToAttributedString: s2]); When 'attriburedString' does not contain image attachments, 1 is logged. When 'attributedString' does contains image attachments, 0 is logged. Is this the expected behavior? The correct behavior? - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Can an app query the values in its own Info.plist?
On Sep 28, 2009, at 1:34 AM, Kyle Sluder wrote: Done. rdar://problem://7257097 Also notes that the same collision issue exists for user defaults, where AppKit stores window and splitter autosave information. It is unlikely that any apple framework is ever going to introduce a key of the form com.your-domain.KeyName If you define your custom Info.plist keys using reverse DNS style keys, the collision issue should become a non-issue. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [UNSOLVED] How to observe every child entity
First, a bit about terminology. What you are talking about is not observing child entities. You wish to observe related instances (NSManagedObject or subclass thereof). The entity describes the instance, but is not the instance. (I'm trying to avoid being overly pedantic, but talking about things using a common language that everyone agrees upon is important.) On Sep 16, 2009, at 9:25 PM, Matthew Lindfield Seager wrote: When a user undoes a deletion it calls the primitive accessor which does not emit KVC/KVO notifications. It is correct that when you undo/redo, Core Data does not typically call the public accessors. It does, however, emit the required KVO change notifications when updating the values. (And as such, you can observer the relationship if you need to know when it changes. Self-observing, unfortunately, opens up another can of worms.) If you have a specific situation where NSManagedObject is no emitting KVO change notifications on undo or redo, that would be a bug. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: restoring NSSplitView divider's position
On Sep 3, 2009, at 6:00 PM, kvic...@pobox.com wrote: ps. i do see the method for setting the divider's position... i just don't see how to get the current position for saving. The divider’s current position can be computed by looking at the frames of the subviews (account for both orientation and width of the divider too.) Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Getting a StringPtr from Gestalt on 64-bit
On Sep 2, 2009, at 9:02 PM, Scott Lahteine wrote: My preference pane uses Gestalt(gestaltUserVisibleMachineName, mySInt32), coercing the SInt32 into a StringPtr to get the Machine Name. On 64-bit I get a warning because StringPtr is a 64-bit pointer on that architecture. Does Gestalt() ensure that the returned pointer is in the low 4 gigs of RAM, or is there a more appropriate way to get the Machine Name that is 64-bit compatible? extern CFStringRef CSCopyMachineName(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Replace NSScroller instances in NSScrollView?
I have a subclass of NSScrollView in which I'm also using a custom NSScroller subclass. If I am unarchiving from a NIB, I can set the object classes for the NSScroller to my subclass. However, there doesn't appear to be an API to specify the class of the scroller used when I alloc+init an NSScrollView, nor does there seem to be an API to replace the default scrollers with my custom scrollers. Have I overlooked the solution? Thanks, Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Replace NSScroller instances in NSScrollView?
On Aug 21, 2009, at 12:22 PM, Jim Correia wrote: I have a subclass of NSScrollView in which I'm also using a custom NSScroller subclass. If I am unarchiving from a NIB, I can set the object classes for the NSScroller to my subclass. However, there doesn't appear to be an API to specify the class of the scroller used when I alloc+init an NSScrollView, nor does there seem to be an API to replace the default scrollers with my custom scrollers. Have I overlooked the solution? Yes. There are public accessors to replace the scroller. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSArrayController subclass computed property not being updated
On Jul 29, 2009, at 1:09 AM, Alexander Heinz wrote: I've got an NSArrayController subclass with a computed property: @property (readonly) BOOL canRemoveSelection; (This basically adds some application-specific checks to the canRemove: property, so that I can bind a remove button in Interface Builder.) I want the property to be recomputed every time the selectionIndex or selectionIndexes of the array controller change, so, in my .m file, I have: + (NSSet*)keyPathsForValuesAffectingCanRemoveSelection { return [NSSet setWithObjects:@selectionIndex, @selectionIndexes, nil]; } [...] Does anyone see anything immediately wrong here? My previous post explains why this doesn't work: http://lists.apple.com/archives/Cocoa-dev/2009/Apr/msg01683.html Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UUID method Garbage Collection safe?
On Jul 22, 2009, at 3:42 PM, Squ Aire wrote: Yes I was aware of this method. However, according to the docs it only guarantees uniqueness for a given process, and doesn't guarantee it will be globally unique, if you know what I mean. Thanks for the suggestion though. The documentation for -[NSProcessInfo globallyUniqueString] does guarantee that the string will be globally unique. (The word global is right in the name.) What it it doesn't guarantee, though, is that it will give you back a UUID string (which is generally meant to be a specific kind of globally unique string.) -globallyUniqueString returns UUID strings today, but this wasn't always true. (And since it isn't guaranteed by the docs, may not be true in the future.) If you specifically need a UUID string, you should probably use CFUUID. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: AppleScript Record and NSDictionary
On Jul 21, 2009, at 6:51 PM, Steve Cronin wrote: From my Cooca app I want to call an AppleScript with several parameters one of which is an AppleScript record. [...] When I look at the docs for -recordDescriptor and I see the 4 character code business - I get the ugly sinking feeling but maybe that's the only way... I've tried to move the coercion into AppleScript but there is nothing that will do that except the magic 'user record fields'. But there are warnings about resouce use for the 'magic' values (And anyway while seated in front of this machine, I don;t really like magic!!) - (NSAppleEventDescriptor) coerceDictionary(NSDictioanary *)dictionary { NSAppleEventDescriptor *result = [NSAppleEventDescriptor recordDescriptor]; NSArray *keysArray = [dictionary allKeys]; NSArray *valuesArray = [dictionary allValues]; unsigned int keyCoount = [keysArray count]; for ( i = 0; i keyCount; i++) { //the good stuff happens here } return result; } So is there an exprienced soul out there who might share a snippet of code or a an illuminating link? Since you omitted // the good stuff happens here it isn't clear to me what, if anything, you've already tried. An AE record is keyed by four character codes. There is a special key - keyASUserRecordFields - which is an AEList of sequential keys and values. When this is present in the record, these appear as string keys to AppleScript. So, create an AE record, and add an appropriate list to the record with the key of keyASUserRecordFields. Whether you write this code using the C API or the Foundation NSAppleEventDescriptor API is now just an implementation detail :-) Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best approach for selective spell-checking...
On Jul 20, 2009, at 9:48 PM, Daniel Jalkut wrote: I'm trying to figure out how to prevent spell checking in my NSTextView from being applied to certain ranges within the text document. [...] It would be nice if NSSpellChecker offered a delegate relationship, something like willMarkMispelledWordInRange: ... where I could choose to have it keep quiet instead. On 10.5 and later, there is public API which you can override in your NSTextView subclass: - (void)setSpellingState:(NSInteger)value range:(NSRange)charRange; // May be called or overridden to control setting of spelling and grammar indicators. Values are those listed for NSSpellingStateAttributeName. Calls the delegate method textView:shouldSetSpellingState:range:. or the delegate variant: - (NSInteger)textView:(NSTextView *)textView shouldSetSpellingState: (NSInteger)value range:(NSRange)affectedCharRange; // Delegate only. Allows delegate to control the setting of spelling and grammar indicators. Values are those listed for NSSpellingStateAttributeName. If you need to support 10.4, perhaps you can use a custom layout manager which avoids setting the temporary spelling attributes for ranges you don't wish to display misspellings for. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView help
On Jul 20, 2009, at 11:49 PM, Dave DeLong wrote: The problem I'm facing is that in order to display the RTF data properly, I need an NSTextView, but NSTextView has its own enclosing scroll view that's conflicting with my overall scrollview. NSTextView doesn't intrinsically have its own scroll view. When you drag a text view (or a table view) out of the Library pallet in IB, you are actually dragging an NSScrollView with an NSTextView as the document view since this is a typically useful configuration. If some other configuration is more useful to you, feel free to configure the view hierarchy that way. Look at the TextSizingExample in the examples folder for examples of other common configurations. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Clarification on accessors? (was: Yet another memory management question)
On Jul 9, 2009, at 5:52 PM, Charles Srstka wrote: On Jul 9, 2009, at 4:29 PM, Ben Trumbull wrote: It may be that under certain circumstances (dictionary storage, synthesized properties on 10.5, etc) that you must use an accessor method even in init dealloc. That requires more care, is more error prone, and less flexible. In particular, additional behavior should not be adorned to the accessor, and the accessor must never leak knowledge of the receiver to a third party during init or dealloc. Basically, these accessors must be very very boring. But if it's a synthesized accessor, wouldn't it be pretty much a given that that would be the case? That will be the case for your class, with its synthesized accessors. If a subclass overrides those accessors, though, you'll be invoking them during setup and teardown too. The overridden accessors, by definition, add side effects or behavior. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSLinkAttributeName: can I control the visual presentation?
On Jul 4, 2009, at 9:18 AM, Stuart Malin wrote: I have a mutable attributed string that is displayed in an NSTextView. For a certain range, I set several attributes, including NSLinkAttributeName. However, the presentation shows as blue underlined text even though I have set other attributes for the font color and also have set the underline style to none. Is there something else I must do to control the visual presentation? On NSTextView: - (void)setLinkTextAttributes:(NSDictionary *)attributeDictionary; - (NSDictionary *)linkTextAttributes; Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determining OS at Runtime
On Jul 3, 2009, at 1:06 PM, Steve Christensen wrote: For the case of a function, if you're deploying on 10.4 but using a 10.5 function, that function will be weak-linked so doing a runtime check is both faster and more accurate in determining whether a function exists or not. Beware that there have been edge cases in the past where a non-NULL function test will give you a false positive with disastrous results. It goes like this: if (FunctionName != NULL) { FunctionName(x, y, z); } FunctionName was SPI on 10.x but (inadvertently) exported, but API on 10.y. When running on 10.x, your NULL function pointer test will pass, but this is SPI and isn't supported for use. The signature may have changed, or the range of valid input values may be a subset of the supported ones on 10.y. This is not a theoretical problem, but one which has happened in the past. What is the take home lesson here? Test all branches of the code you write. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive
On Thu, Jul 2, 2009 at 11:17 PM, Jerry Krinock je...@ieee.org wrote: If -[NSKeyedUnarchiver unarchiveObjectWithData:] is handed a corrupt archive, it raises an exception AND crashes the program. Do you have a sample app data combo which demonstrates the crash? +[NSKeyedUnarchiver unarchiveObjectWithData:] is documented to raise an exception when feed an incomprehensible archive. If you have no exception handler in place, the program will terminate. But that isn't due to a bug in NSKeyedUnarchiver - it is just working as advertised - whether or not you like the advertised behavior. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSValueTransformer, NSTableView and NSAttributedString
On Jun 23, 2009, at 1:35 AM, Kyle Sluder wrote: On Mon, Jun 22, 2009 at 9:12 PM, Jim Correiajim.corr...@pobox.com wrote: The documentation for the value binding of NSTableView says that NSString and NSNumber are the supported value types. I do not see where you're finding this. The bindings documentation says: The object should be suitable for the passing to setObjectValue. Maybe it's in the conceptual docs? In the link I included in my last email (which was wrapped when sent to the list): http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTextFieldCell.html#//apple_ref/doc/uid/NSTextFieldCell-DontLinkElementID_657 Value Bindings value An NSString or NSNumber that is displayed as the content of the NSTextFieldCell. Availability: - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSValueTransformer, NSTableView and NSAttributedString
On Jun 23, 2009, at 11:06 AM, Kyle Sluder wrote: On Tue, Jun 23, 2009 at 6:53 AM, Jim Correiajim.corr...@pobox.com wrote: On Jun 23, 2009, at 1:35 AM, Kyle Sluder wrote: I do not see where you're finding this. The bindings documentation says: The object should be suitable for the passing to setObjectValue. Maybe it's in the conceptual docs? In the link I included in my last email (which was wrapped when sent to the list): Okay... but you are aware that's the documentation for NSTextFieldCell, not NSTableColumn? Bindings in a table view are done on the table column, not on the cells themselves. Correct. I should have read the original question more carefully. Binding an NSTableColumn to a model object property which returns an NSAttributedString works correctly. As does binding to a property through a value transformer which returns an NSAttributedString. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with NSValueTransformer, NSTableView and NSAttributedString
On Jun 21, 2009, at 10:37 AM, Donnie Lee wrote: I created NSTableView and bind table column with NSTextFieldCell with custom NSValueTransformer subclass to NSArrayController. My value transformer should return NSAttributedString transformed from NSString. Everything works fine except that the table shows NSString instead of NSAttributedString. It looks like: My text{NSFont = LucidaGrande}. How to make the right behavior for my value transformer? The documentation for the value binding of NSTableView says that NSString and NSNumber are the supported value types. http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTextFieldCell.html#/ /apple_ref/doc/uid/NSTextFieldCell-DontLinkElementID_657 Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Possible to set tab stops in an NSTextView?
On Sun, Jun 21, 2009 at 11:44 AM, Ken Tozier kentoz...@comcast.net wrote: I'm working with an NSText view and want to display tab delimited strings in a table format. I don't need a full NSTable, just the ability to break up the text into columns using tab stops. Is there any built-in way to do this? Something like setTabStops? I looked in NSTextView, NSText, NSTextContainer and NSAttributedString but didn't see anything. Tab stops are controlled via NSParagraphStyle. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Add same object/key to NSMapTable
On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner b...@mac.com wrote: You can't assume that the container didn't make a copy or do something else. If you need the object, you should hold a retain. In general, I agree. However, the following code is also problematic: [o release]; [testTable setObject:[testTable objectForKey:k] forKey:k]; NSDictionary does not have the same failure mode. Bug in NSMapTable (for the edge case of replacing the current value)? - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: orderFrontStandardAboutPanel problem on Tiger - [NSCFDictionary setObject:forKey:]: attempt to insert nil value
On Mon, Jun 1, 2009 at 7:29 AM, Chris Jones littlemaca...@gmail.com wrote: The error is: [NSCFDictionary setObject:forKey:]: attempt to insert nil value. And the StandardAboutPanel does not appear. [...] I don't think it could get more simple, but I can't see where I'm passing a nil value. I thought this was related to a missing piece of info in info.plist, but all required fields seem to be present. Set a breakpoint on -[NSCFDictionary setObject:forKey:] and a condition for when the object parameter is nil. (The specific condition is going to depend upon what architecture you are debugging in.) When you stop there, examine the value for the key. Hopefully at that point the problem is obvious. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [ NSSplitview ] -setAutosaveName
On Sat, May 30, 2009 at 11:22 PM, Erg Consultant erg_consult...@yahoo.com wrote: What does setAutosaveName actually do? I assume it saves the position of the splitview to user defaults? The behavior is documented, succinctly, here: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/nssplitview_Class/Reference/Reference.html#//apple_ref/occ/instm/NSSplitView/setAutosaveName: If so, how does one retrieve that value? You typically don't, since the actual key and format of the data is a private implementation detail. NSSplitView will restore the geometry for you automatically. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [ NS KeyedArchiver ] archiveRootObject:toFile: hoses my directory's permissions
On Sat, May 30, 2009 at 1:39 AM, Erg Consultant erg_consult...@yahoo.com wrote: Why does archiveRootObject:toFile: change the permissions on the parent directory? I didn't ask it to. This dir has to be writable for all users - the way I installed it - not by only the current user. How can I avoid having the permissions changed? Show your code. In a trivial sample app here, this is not the behavior I observe. - JIm #import Foundation/Foundation.h int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *outputFilePath = [@~/Desktop/output-parent/outputfile.keyedArchive stringByExpandingTildeInPath]; NSString *outputDir = [outputFilePath stringByDeletingLastPathComponent]; NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedInt: 0777] forKey: NSFilePosixPermissions]; BOOL success = NO; success = [[NSFileManager defaultManager] createDirectoryAtPath: outputDir attributes: attributes]; success = [NSKeyedArchiver archiveRootObject: @my object toFile: outputFilePath]; attributes = [[NSFileManager defaultManager] attributesOfItemAtPath: outputDir error: NULL]; NSLog(@permissions = %o, [[attributes objectForKey: NSFilePosixPermissions] unsignedIntValue]); [pool drain]; return 0; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSEvent virtual keycodes
On Mon, May 18, 2009 at 10:44 PM, Christopher Hansen christopher.han...@yahoo.com wrote: The NSEvent Reference documentation for the keyCode method states that the value returned is the same value returned in the kEventParamKeyCode when using Carbon Events. Are the virtual key codes available in a Cocoa-based header? The only virtual keycode definitions I've been able to find are in Carbon/HIToolbox/Events.h. That is the only place they are currently defined. Including that header will not give your code cooties. That's currently the correct place to pick up the constants from. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Predicate Bug?
On Sat, May 16, 2009 at 8:13 AM, ALEXander alexan...@wackazong.com wrote: I am currently developing a Core Data Application. I have an entity (set) with a boolean attribute 'isActive' (optional, non-transient, non-indexed, default NO). For some of my objects, this attribute is set to YES. There is another entity (control) with a to-one relationship to a set. The problem occurs when saving and reopening a document: If I use a predicate in a fetch request for the entity control which contains a predicate format string like @set.isActive == YES, no objects are returned. Before saving and reopening, the correct objects are returned. How can that happen? I know (by looking at the data with the pre-built core data entity interfaces from IB) that there are objects where that predicate is true. To me, this is a bug. But of course, I hope to be wrong. Do you have a standalone sample which demonstrates this problem? From the description above, it is hard to say what might be going on. Writing a standalone sample can be tedious and time consuming. But in the process of doing so, you may discover that this is actually a bug in your code/logic. If not, then you'll have a shareable sample that you can show us and attach to a bug report. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Which field is the NSTextFieldCell drawing?
On Sat, May 16, 2009 at 9:05 PM, K. Darcy Otto do...@csusb.edu wrote: I have an NSTextFieldCell subclass that needs to draw itself differently depending on which NSTableView row it is drawing. My current solution is to store the row that is being drawn in my document class in an instance variable (the assignment is done in -tableView:willDisplayCell:forTableColumn:row:), and have my NSTextFieldCell read out that variable prior to drawing itself. Is there a more direct way to do this? Is it possible to either: (1) Have the NSTextFieldCell subclass look up the row that is currently being drawn, or (2) Store the row to be drawn in an instance variable of the NSTextFieldCell. I think (1) would be the easiest. What is preventing (1) is that I'm not sure how to query the NSTableView to ask it what object is currently being drawn. What is preventing (2) is that I'm not sure how to get a pointer to the NSTextFieldCell subclass object that is about to be drawn, and insert the appropriate information just before it is drawn. -tableView:willDisplayCell:forTableColumn:row: *is* your hook to do this. In that delegate method, set any additional properties on your cell that you need at display time. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Which field is the NSTextFieldCell drawing?
On Sun, May 17, 2009 at 12:08 PM, K. Darcy Otto do...@csusb.edu wrote: Thank you. The thing is, the cell object returned by -tableView:willDisplayCell:forTableColumn:row: is not from my NSTextFieldCell subclass but rather the superclass – even though it is the subclass doing the drawing. Any idea how to address the subclass object directly? The instance passed to -tableView:willDisplayCell:forTableColumn:row: is the same instance that is used to draw the cell. If you are seeing an instance of NSTextFieldCell instead of an instance of MyFancyTextFieldCell, you must have a configuration issue. How are you setting up the table column for your cell subclass? Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -[NSScriptCommand suspendExecution]
On Fri, May 15, 2009 at 12:26 PM, kvic...@pobox.com kvic...@pobox.com wrote: if i call -[NSScriptCommand suspendExecution] whilst execution a script command, i find that the executing script will still time out after 2 minutes. is this a bug in cocoa? or a misunderstanding on my part about suspendExecution? A misunderstanding on your part about how things work. Even if you -suspendExecution and later return a result, the timeout that the sender specified when they sent the event - how long they were willing to wait for either an answer or a timeout error - is still in force. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTask temrinationStatus always == 1?
On Sun, May 10, 2009 at 2:18 PM, marc hoffman m...@elitedev.com wrote: i have an odd issue with NSTask. for some reason, no matter what result code my executable returns (im running xcodebuild, if that matters), NSTask's terminationStatus always reports back as 1. if instead i use system() to run the exact same command, i get bak proper error codes (0 for success., other non-zero, non-one values for real failures. anyone have any ideas what could be going wrong to cause this? You'll have to show your code. NSTask correctly returns the exit code (see below). NSTask *task = nil; task = [NSTask launchedTaskWithLaunchPath: @/usr/bin/true arguments: [NSArray array]]; [task waitUntilExit]; NSLog(@terminationStatus = %d, [task terminationStatus]); task = [NSTask launchedTaskWithLaunchPath: @/usr/bin/false arguments: [NSArray array]]; [task waitUntilExit]; NSLog(@terminationStatus = %d, [task terminationStatus]); - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTask temrinationStatus always == 1?
On Sun, May 10, 2009 at 2:18 PM, marc hoffman m...@elitedev.com wrote: i have an odd issue with NSTask. for some reason, no matter what result code my executable returns (im running xcodebuild, if that matters), NSTask's terminationStatus always reports back as 1. if instead i use system() to run the exact same command, i get bak proper error codes (0 for success., other non-zero, non-one values for real failures. You'll have to show your code. NSTask correctly returns the error code (see below). NSTask *task = nil; task = [NSTask launchedTaskWithLaunchPath: @/usr/bin/true arguments: [NSArray array]]; [task waitUntilExit]; NSLog(@terminationStatus = %d, [task terminationStatus]); task = [NSTask launchedTaskWithLaunchPath: @/usr/bin/false arguments: [NSArray array]]; [task waitUntilExit]; NSLog(@terminationStatus = %d, [task terminationStatus]); - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
On Wed, May 6, 2009 at 1:05 PM, Jerry Krinock je...@ieee.org wrote: In any case using multiple MOCs for different jobs is a good idea. Accessing the same store? I always thought that was a bad idea, but I'll give it some thought. Using multiple MOCs with a single persistent store coordinator is supported. It is pattern #1 in the Core Data threading documentation. http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdMultiThreading.html#//apple_ref/doc/uid/TP40003385-SW2 Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: -[CALayer hitTest:] incorrect when embedding layer-backed NSView subclass inside NSScrollView
On Mon, May 4, 2009 at 6:19 PM, Steven Degutis steven.degu...@gmail.com wrote: Specifically, you'll notice that the -hitTest: returns the correct layer *only* if you click the view while it is fully visible in the window, and before you have made it not-fully-visible for the first time. After you resize the scroll view to hide any portion of this NSView subclass, -hitTest: will consistently return the wrong layer every time. [...] - (void) mouseDown:(NSEvent*)event { NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; CALayer *layer = [self.layer hitTest:NSPointToCGPoint(point)]; NSLog(@%@, [layer name]); } I've tried to replace `self` with the enclosing scroll view, or its content view or document view, in the -mouseDown: method, and many combinations of this. Nothing seems to do the trick. -hitTest on CALayer, like NSView, takes a point in the superlayer's coordinate system. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why is NSString-FSRef so hard?
On Thu, Apr 30, 2009 at 12:02 AM, Charles Srstka cocoa...@charlessoft.com wrote: With that said, I don't really see what is harmful about recommending the use of NSString's path concatenation methods, which could save quite a few headaches in the case that this *does* somehow change for some bizarre reason, however unlikely that may be. Even if the path separator never changes, they are still beneficial to use because they automatically handle both the trailing slash present and trailing slash missing cases transparently [@/foo stringByAppendingPathComponent: @bar] - /foo/bar [@/foo/ stringByAppendingPathComponent: @bar] - /foo/bar - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Key Value Coding is not case-sensitive?
On Tue, Apr 28, 2009 at 12:09 AM, DairyKnight dairykni...@gmail.com wrote: And have the following set methods: -(void) setfido ... -(void) setFido ... Both by calling [self setValue: ... forKey:@fido] or [self setValue:... forKey:@Fido], the runtime would call the same 'setFido' method. How could this be? -setfido is not a KVC compliant method name. Fido is not a KVC compliant iVar name. (Though generally you should be using KVC via accessor methods and not via direct iVar access anyway.) http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/Compliant.html - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie
On Sun, Apr 26, 2009 at 10:41 AM, Jerry Krinock je...@ieee.org wrote: // Table View delegate method. // A little more complicated since we have to dig into the // parts of the table, and assign it as a header cell. - (void) tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn { NSTableHeaderView *headerView = [tableView headerView] ; NSPopUpButtonCell* popUpCell = [[NSPopUpButtonCell alloc] init] ; [tableColumn setHeaderCell:popUpCell] ; [popUpCell setMenu:[self makeMenu]] ; [popUpCell performClickWithFrame:NSZeroRect inView:headerView] ; [popUpCell release] ; } What you've done is replaced the table column's header cell, and started a menu tracking session while the table view was already in the middle of a mouse tracking session. What are you really trying to accomplish here? It is hard to offer advice without knowing what you want to build. But you are probably going to want to take the approach of using a custom header view (along with custom header cells as necessary.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: figuring out which TableView I am?
On Sun, Apr 26, 2009 at 7:05 PM, WT jrca...@gmail.com wrote: More importantly, perhaps, is the fact that adding property/ivars is not a scalable solution in that it requires adding more code in several places if more tables are added. The tags solution only requires some fiddling with IB and updating a switch statement. That sounds to me a much simpler maintenance problem than having to update code in several places. I guess I'm not following your logic. I want table 1 to have a blue background, so I set its tag to 3. I want table 2 to also have a blue background, so I set its tag to 3. I want table 1 to have red text. Switch off tag, 3 == red text. I want table 2 to have green text. Oops - tag 3 already means blue background + red text. (Substitute any 2 actual properties for my background color + text color - they are meant for illustration purposes only.) Overloading tags for other properties is not scalable, because you only have one property (the tag) which you are overloading to mean N other properties and/or behaviors. The only scalable solution to this problem is explicity iVars/properties for each property/behavior you want to control in your subclass. (Yes, this means configuring things by hand after unarchiving your nib, or writing an IB plug-in so you can specify them in IB.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: figuring out which TableView I am?
On Sun, Apr 26, 2009 at 8:04 PM, Graham Cox graham@bigpond.com wrote: This is true, but your example of non-scalability does reflect a poor approach that you wouldn't be likely to follow in practice. A tag is 32 bits, so can represent 2^32 different states, if used wisely. Dividing this into bitfields would allow you to partition it into several properties, for example four different colour properties, each with 256 possible colours each. Even when used as a bitfield, I'd still argue it is not good design. (It might be an expedient hack to get something done, and if you are happy with that as a solution, great.) It overloads the tag to imply control behavior/appearance, while at the same time preventing users of your class from using the tag for its original purpose. (Yes, I realize that the the user of the custom table view is the same person as the provider of the custom table view.) - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Trying to get flagsChanged: to work
On Sat, Apr 25, 2009 at 1:19 PM, Dave DeLong davedel...@me.com wrote: It seems that the responder chain is not set up during awakeFromNib (even though all the outlets are), because I moved the loop to my addGroup: IBAction, where it printed off my chain. My GroupListController was not in the chain. Shouldn't it be? Doesn't a view's controller get a chance to respond to anything that the view doesn't respond to? No, an NSViewController is an NSResponder subclass, but if you want it to be part of the responder chain, it is your responsibility to link/unlink it into the responder chain at the right place when appropriate. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Data: thread safety of NSPersistentStore +metadataForPersistentStoreWithURL:... (and +set...)?
I don't see that the documentation specifically calls out @interface NSPersistentStore + (NSDictionary *)metadataForPersistentStoreWithURL:(NSURL *)url error: (NSError **)error; + (BOOL)setMetadata:(NSDictionary *)metadata forPersistentStoreWithURL: (NSURL*)url error:(NSError **)error; @end as being thread safe. (And in fact, these are abstract and need to be implemented by the concrete stores.) (Outside of the obvious potential race condition) Is it intended that these methods are thread safe for Apple-supplied persistent stores (i.e. concurrently and/or non-main-thread callable)? Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem implementing keyPathsForvaluesAffectingKey
On Apr 22, 2009, at 10:45 AM, jonat...@mugginsoft.com wrote: The property canDelete is dependent on three other properties as shown below. Is there a problem with my implementation of + keyPathsForValuesAffectingCanDelete with regard to the key path @arrayController.canRemove? Is is a relatively well known issue that NSKeyValueObservingOptionNew and NSKeyValueObservingOptionOld do not work with controller properties. See: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html What is perhaps less well known is that controller keys which don't support the New/Old KVO observing options also don't support NSKeyValueObservingOptionPrior. The +keyPathsForValuesAffectingKey mechanism relies on NSKeyValueObservingOptionPrior in order to do its magic. Until such time as controller keys correctly support the KVO observing options, you can't a) rely on Old/New/Prior in your own observers b) use a controller property as part of a key path in +keyPathsForValuesAffectingKey - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ESC while editing NSOutlineView subclass
On Thu, Apr 23, 2009 at 5:16 PM, Kevin Gessner ke...@kevingessner.comwrote: I've got this in MyEditorOutlineView, my NSOutlineView subclass. - (void)keyDown:(NSEvent *)theEvent { [super keyDown:theEvent]; NSLog(@keyDown: %d, [theEvent keyCode]); #define returnKeyCode 36 switch([theEvent keyCode]) { case returnKeyCode: if([[self delegate] respondsToSelector:@selector(newSiblingInEditor:)]) { [(NSObjectMyEditorOutlineViewDelegate *)[self delegate] newSiblingInEditor:self]; } break; } } But it's never called when there's an editing session. When you are in the middle of an editing session, the first responder is the field editor. The field editor receives, and consumes, the keydown events. Look at the NSResponder documentation for the -cancelOperation: method. This should be bubbled up the responder chain if when escaped is pressed and the field editor is active. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Fetches + Transient Properties + NSPredicateEditor = Sadness
On Apr 20, 2009, at 2:02 PM, Jerry Krinock wrote: A much better way appears to be to fetch all objects from the store with no predicate and then use -[NSArray filteredArrayWithPredicate:]. This takes only one more line of code, solves all problems, and is supposedly cheaper too: If you use the Core Data framework, the array methods provide an efficient means of filtering an existing array of objects without —- as a fetch does —- requiring a round trip to a persistent data store. [...] Makes me wonder why NSFetchRequest even supports a predicate, since its predicate has all these limitations and is supposedly more expensive when compared to fetching all objects and then using - [NSArray filteredArrayWithPredicate:] ? You are taking that quote out of context and misinterpreting it. If you already have an array of NSManagedObjects (fully realized, no faults), then it is going to be faster to filter that array than it is to execute a fetch request with a predicate, which always round trips to the store. They key is if you already have an array... (Or a set.) If you don't, then fetching a limited set with a predicate is (usually) going to be considerably faster than fetching all objects, and reducing the result after the fact with a predicate. Consider what happens when you fetch all objects of a particular type. Now consider what happens if you can give Core Data a predicate which says no, just these 3. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVC and @ as key
On Apr 15, 2009, at 12:19 AM, Micha Fuhrmann wrote: I'm bumping against KVC, indirectly. I've got a dictionary with first character keys, each object of the key is an Array with objects. So key b of my Dictionary is an array with file objects' name starting with the letter b. The problem comes up when users have file names starting with the character @. I'm calling [nameIndexesDictionary @@] and getting What does the code say, exactly. That's not valid Obj-C. [NSCFDictionary 0x2729830 valueForUndefinedKey:]: this class is not key value coding-compliant for the key .' What can I do about it? Any help appreciated. @ is a key path operator. Is the dictionary bound to something, where use of KVC is required? If not you should probably use -objectForKey:. This avoids interpretting the key with KVC rules. Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com