Re: Collections can be simple Attributes in Core Data
Am Fr,26.09.2008 um 03:08 schrieb Jerry Krinock: When I first looked at Core Data, I saw that there was no such attribute type as Array or Set, and concluded that collections must be modelled as relationships. This would be overkill in many cases, for example, in a Person type of application if you wanted to list the names of each Person's pets, but had no interest in the pets themselves. If $user changes the name of one person, the names of the pets shouldn't be changed, too? This overkill simply avoids redundancy to ensure consistency. So, one way I worked around this was to store the pet names as an attribute petNamesString of type String, using a delimiter character, and transforming on the way in and out of the store. This seems to be overkill. ;-) But now I find there is an even more natural way, which is to just leave them as a set or array, and store in an attribute of type Transformable. The default transformer en/decodes the collection into/from an NSData, and everything just works. I'm surprised that I've never seen this discussed or documented. Is this going to get me into any trouble? Yes, because you get redundant and inconsistent model. Cheers Amin Negm-Awad [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Two questions about cocoa programming...
Hi everyone. In the recent development, I need to solve the following two issues: 1. How to distinguish the difference about the inline children count of the XML Node? here is my code: xmlDoc = [[NSXMLDocument alloc] initWithXMLString:[NSString stringWithContentsOfFile:_filePath] options:NSXMLDocumentTidyXML error:err]; NSXMLElement* _rootNode = (NSXMLElement*)[xmlDoc rootElement]; print: [_rootNode childCount]; Here is twe snippets of xml files: #1 ?xml version=1.0 encoding=UTF-8? Descriptor something = something yetAnotherThing floor /floor Man /Man /Descriptor This file outputs answer: 3 // Another similar file output: #2 ?xml version=1.0 encoding=UTF-8? Descriptor something = something floor /floor Man /Man /Descriptor This file outputs answer: 2 Is there any method to detect the existence of the yetAnotherThing node? More concretely, you can nest the node under the parent node with label or not, how to detect the child without being nested by the label? Sorry for my English, I hope I have explained the question clearly. :-) 2. Using openPanel function: how can we memorize the most recent opened directory? As the question says, we often the open panel directive to open file, is there some method to guarantee that we can be the same location which is opened last time? Thank you very much for any help. Good luck. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Load launchd job immediately, without restart - how?
I have a PrefPane that acts as a ui for a command line utility (helper). According to the launchd docs, all I need to do is add the correct plist to the /LaunchAgents folder. However, this will take effect after a restart, which is unacceptable. To load the helper immediately, I need to go through launchctl. So here's my problem: there are virtually no docs on how to use launchctl programmatically, and the sporadic comments google turned up on the subject say it's not worth the trouble. However, I can't seem to find a recommended alternative. It's my understanding that the alternative possibly involves a script to call launchctl, but how would this work, and more importantly, how would it be integrated into the PrefPane code? Any insight would be greatly appreciated! Thanks D. Rolidis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Problem setting the menu
Hello, I am having problems setting a menu for my application. I am writting the application in Object Pascal and I am not using nib files, because the point is being able to use this to port cross-platform GUI libraries. I create a NSMenu and set it to both AppleMenu and MainMenu, or just 1 of them, but nothing happens!! I always get just an empty menu. I have read tutorials out there, but according to them this code should work. I create my menu with this code: MainMenu := CreateMainMenu(); NSApp.setAppleMenu(MainMenu.Handle); NSApp.setMainMenu(MainMenu.Handle); end; function TMyView.CreateToolbar(AOwnerView: NSView; AX, AY, AWidth, AHeight: Double): NSToolbar; begin Result := NSToolbar.initWithIdentifier(CFEmptyString); ToolbarController := TMyToolbarController.Create; Result.setDelegate(ToolbarController.Handle); end; function TMyView.CreateMainMenu(): NSMenu; var Item1: NSMenuItem; MenuTitle: CFStringRef; begin MenuTitle := CFStringCreateWithPascalString(nil, 'Title', kCFStringEncodingUTF8); WriteLn('CreateMenu'); Result := NSMenu.initWithTitle(MenuTitle); WriteLn('Menu Created'); Item1 := CreateMenuItem('Exit', Str_doClose, myController); Result.addItem(Item1.Handle); end; function TMyView.CreateMenuItem(ATitle: shortstring; ACallbackName: string; ACallbackClass: NSObject): NSMenuItem; var ItemText: CFStringRef; KeyText: CFStringRef; begin KeyText := CFStringCreateWithPascalString(nil, '', kCFStringEncodingUTF8); ItemText := CFStringCreateWithPascalString(nil, ATitle, kCFStringEncodingUTF8); WriteLn(' ItemText: ', IntToHex(Int64(ItemText), 8), ' ATitle: ', ATitle); Result := NSMenuItem.initWithTitle_action_keyEquivalent(ItemText, nil, KeyText); Result.setTarget(ACallbackClass.Handle); Result.setAction(sel_registerName(PChar(ACallbackName))); end; thanks, -- Felipe Monteiro de Carvalho ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Crash with toolbars
Hello, I am having a problem with toolbars. I have created a delegate class for my toolbar, but when I added the toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: method it crashes: Exception: EXC_BREAKPOINT (0x0006) Code[0]:0x0002 Code[1]:0x Thread 0 Crashed: 0 com.apple.Foundation0x9282a45f _NSRaiseError + 227 1 com.apple.Foundation0x92851247 +[NSException raise:format:] + 57 2 com.apple.Foundation0x9285108c _NSArrayRaiseInsertNilException + 75 3 com.apple.Foundation0x927f47fc -[NSCFArray insertObject:atIndex:] + 125 4 com.apple.AppKit0x933c5279 -[NSToolbar _forceInsertItem:atIndex:] + 364 5 com.apple.AppKit0x933c4df2 -[NSToolbar _insertNewItemWithItemIdentifier:atIndex:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults:] + 152 6 com.apple.AppKit0x933c4d52 -[NSToolbar _appendNewItemWithItemIdentifier:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults:] + 97 7 com.apple.AppKit0x933c4b94 -[NSToolbar _setCurrentItemsToItemIdentifiers:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults:] + 335 8 com.apple.AppKit0x933c43a4 -[NSToolbar _loadFromUDIfNecessary] + 231 9 com.apple.AppKit0x933c3b36 -[NSToolbar _setToolbarViewWindow:] + 190 10 com.apple.AppKit0x933c38ca -[NSWindow setToolbar:] + 395 11 org.magnifier.magnifier 0x00037c97 APPKIT_NSWINDOW_$__SETTOOLBAR$POBJC_OBJECT + 71 (NSWindow.inc:2205) 12 org.magnifier.magnifier 0x0003e315 VIEW_TMYVIEW_$__CREATEUSERINTERFACE + 453 (view.pas:74) 13 org.magnifier.magnifier 0x20fd PASCALMAIN + 173 (texteditor.pas:46) 14 org.magnifier.magnifier 0x0001be85 FPC_SYSTEMMAIN + 69 15 org.magnifier.magnifier 0x2032 _start + 216 16 org.magnifier.magnifier 0x1f59 start + 41 I am using this string as the type encoding for my delegate method, and this declaration: @@:@@L class function toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar (_self: objc.id; _cmd: SEL; toolbar: objc.id; itemIdentifier: CFStringRef; flag: CBOOL): objc.id; cdecl;// static; I suppose that the bool used in the routine will be mapped to a long, is that it? What is the adequate type encoding for a bool in Objective-C? The docs says nothing about this. Here is my code: constructor TMyToolbarController.Create; begin { The class is registered on the Objective-C runtime before the NSObject constructor is called } if not CreateClassDefinition(ClassName(), Str_NSObject) then WriteLn('Failed to create objc class ' + ClassName()); inherited Create; { Prepare CFStringRefs for the constants } OpenToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'OpenID', kCFStringEncodingUTF8); SaveToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'SaveID', kCFStringEncodingUTF8); CloseToolbarItemIdentifier := CFStringCreateWithPascalString(nil, 'CloseID', kCFStringEncodingUTF8); end; procedure TMyToolbarController.AddMethods; begin AddMethod(Str_toolbarAllowedItemIdentifiers, '@@:@', Pointer(toolbarAllowedItemIdentifiers)); AddMethod(Str_toolbarDefaultItemIdentifiers, '@@:@', Pointer(toolbarDefaultItemIdentifiers)); AddMethod(Str_toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar, '@@:@@L', Pointer(toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar)); end; class function TMyToolbarController.toolbarAllowedItemIdentifiers(_self: objc.id; _cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl; var toolbarItems: array[0..3] of CFStringRef; begin toolbarItems[0] := OpenToolbarItemIdentifier; toolbarItems[1] := SaveToolbarItemIdentifier; toolbarItems[2] := CloseToolbarItemIdentifier; toolbarItems[3] := nil; Result := CFArrayCreate(nil, @toolbarItems[0], 4, nil); end; class function TMyToolbarController.toolbarDefaultItemIdentifiers(_self: objc.id; _cmd: SEL; toolbar: objc.id): CFArrayRef; cdecl; begin Result := toolbarAllowedItemIdentifiers(_self, _cmd, toolbar); end; class function TMyToolbarController.toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(_self: objc.id; _cmd: SEL; toolbar: objc.id {NSToolbar}; itemIdentifier: CFStringRef; flag: CBOOL): objc.id {NSToolbarItem}; cdecl; var toolbarItem: NSToolbarItem; begin if CFStringCompare(itemIdentifier, OpenToolbarItemIdentifier, kCFCompareCaseInsensitive) = kCFCompareEqualTo then begin toolbarItem := NSToolbarItem.initWithItemIdentifier(itemIdentifier); //[toolbarItem setLabel:@Save]; // [toolbarItem setPaletteLabel:[toolbarItem label]]; //[toolbarItem setToolTip:@Save Your Passwords];} toolbarItem.setImage(myModel.imgOpen.Handle); toolbarItem.setTarget(myController.Handle); toolbarItem.setAction(sel_registerName(PChar('doOpenFile:'))); end else if CFStringCompare(itemIdentifier, SaveToolbarItemIdentifier, kCFCompareCaseInsensitive) = kCFCompareEqualTo then begin toolbarItem :=
Setting automatic alignment
Hello, Is it possible to have a control automatically expand as the window is resized? I have a toolbar and a text area and I would like the text area to automatically increase size as the window is resized. Is there a clever property for this? Also, is it possible to change the coordinates system when placing controls? Starting at the bottom-left is rather inconvenient. I would much rather have top-left like most libraries use. Also note that I am not using the Interface Building, so the answer should involve code. thanks, -- Felipe Monteiro de Carvalho ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
How to develop a Safari event listener
Hi to all, I am trying to develop a small tool, it can be an appliction/bundle/plug-in ... The goal is, when Safari opens certain web page, like www.apple.com, the tool will be launched automatically, and it can get the page's url. I know for firefox, people call this kind of tool as add-on, not sure what it's exactly called for Safari. I tried to do it with Web Kit plug-in. But as I learned, Web Kit plug-in only works when the web page has certain embed tag, like 'mov', that was defined in the MIME type that the plug-in registered for. But in my case, I want the tool to work for any web page Safari opened. Any one has any suggestion on how to do this? thank you all for your kind support! Bill ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: showing window causes EXC_BAD_ACCESS
Am Sa,27.09.2008 um 22:44 schrieb Uli Kusterer: On 27.09.2008, at 22:13, Michael Ash wrote: But suddenly you're back to having to think about the global picture of who owns objects, which is what Cocoa's memory management system is supposed to avoid. Retains and releases should be balanced. This doesn't just means that they should ultimately be equal in number, it also means that the same entity should be doing both. Release when closed breaks the fundamental memory management rules and, as a consequence, makes it much more complicated to think about how the program works. You're misunderstanding the purpose of Cocoa's memory management system: It's not about not having to care who owns what, it's about not having to worry about shared ownership. There are many cases (threading and creation of objects come to mind) where ownership is handed from one object to the other. In this case, you specify in the NIB that you want your window to release itself, and you haven't written your outlet in a way that it retains the window. If you expect your window to not go away when closed, you're expecting too much. Hallo Uli, :-) I think, that you have to keep in mind, that sometimes you have instances in a nib, which have no retain at all. Simply think of a stand-alone delegate for an UI-element. It is not retained by the UI- element (delegates are not retained to avoid retain cycles as you know). So loading a nib unfortunatly is not balanced. When you think of loading the nib-objects as instance creation, the mm-rules are broken: Usually you balance the +alloc with a -retain (some lines later, sometimes in -dealloc) or an immediate -autorelease. The nib-loader does not do that. So $somebody has to release the instances, when the nib is unloaded. So loading objects through the nib-loader is like a naked +alloc, - init*. You can see eht nib-exception of mm-rules, when you handle the top- level objects your own. You probably store them in an array, which sends a retain to the objects. The first thing you have to do, is to send a -release to all top-level objects to balance the nib-loaders +alloc. So, after all: You have to release top-level objects of the nib manually, when unloading the nib. I think, that release, when closed is simply a convenient option, because in many cases you have only a window in the nib and it is the only object, that has to be released. And usually closing a window means unloading the nib to get the free memory. So in this cases you have to do nothing in your code, if you checked that option. That said, I fully agree on one partial point you raised: 'Release when closed' is dangerous and complicates matters. Yes. Anyway you should always use a window controller or view controller to get rid of the problems with nibs and mm. It should be off by default, and it's very likely that nobody would miss it. In this case, you will get a memory leak everytime you simply do not care about the nib loading. You would always need extra release-code. Think of a simple about-window. You have an action, let's call it - showAboutWindow: and load the nib there. If the user closes this window, it is released automatically. You have to do nothing. And you do not have to take care about other instances in that nib, because there are no other instances: 0 lines of code. (In reality this is not true, because you have to take care, that the nib is not reloaded. So you have to handle the window close for that purpose and then can add a -release.) That said, I don't know what it was originally introduced for. Any old NeXTies here who know? longW told me, that there had not been window controllers prior to 10.0 to handle the mm of nib-objects. :-) view controllers are introduced with 10.5. So the whole nib-loading mechanism looks a littlebit – eh – archaeological. Cheers, Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Setting automatic alignment
On 29 Sep 2008, at 00:51, Felipe Monteiro de Carvalho wrote: Hello, Is it possible to have a control automatically expand as the window is resized? I have a toolbar and a text area and I would like the text area to automatically increase size as the window is resized. Is there a clever property for this? -[NSView setAutoresizingMask:] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Restoring a .nib's Edit menu
Drag the Edit Menu from the Library into the main .nib window. Then drag it up to the MainMenu and it will insert ok. Cheers Kevin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Mouse events with higher priority then repeating NSTimer
Hi guys, I'm trying to render the stage with a default interval. When the needed time to render the scene is higher than the interval itself, the application doesn't process anymore the mouse events. I'm setting the timer once with [NSTimer scheduledTimerWithTimeInterval]. I'm thinking of recreating a not repeating timer every time it fires, but I'm wondered if there is a better way. Is there any other way you would recommend to have a continuous rendering without making the app not reactive? Thanks, chr ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSManagedObject custom class for loop
Hi folks, In my core data app I have an Account entity. I've subclassed this as I want to add a method that calculates the Account's balance by doing a fetch on Transaction entities and tallying up the amounts. I've created a custom class in xcode and added the following code in Account.m #import Account.h @implementation Account @dynamic name; @dynamic envelopeVisible; @dynamic accounts; @dynamic out; @dynamic type; @dynamic in; @dynamic envelope; //custom stuff - (NSNumber *)balance { // we fetch all the transactions our account is related to and tally up the balance NSNumber *balance; NSManagedObjectContext *moc = [self managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@Transaction inManagedObjectContext:moc]; [request setEntity:entity]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@toAccount = %@, self]; [request setPredicate:predicate]; NSError *error = nil; NSArray *transactions = [moc executeFetchRequest:request error:error]; if (transactions == nil){ NSLog(@Account balance fetch returned nil); } NSLog(@Account balance for %@ counted %d transactions,[self name], [transactions count]); //iterate through transactions and tally balance NSManagedObject *transaction; for (transaction in transactions){ NSNumber *amount = [entity amount]; balance = [NSNumber numberWithFloat:[balance floatValue] - [amount floatValue]]; } return balance; } @end The problem is when the code hits the for (transaction in transactions) loop it dumps to GDB with an obj_msgsend error and I can't see why. Am I trying to do something that a custom class shouldn't be able to do? If I comment out the loop it runs fine. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Load launchd job immediately, without restart - how?
On 2008 Sep, 28, at 7:49, Dimitris Roilidis wrote: I have a PrefPane that acts as a ui for a command line utility (helper). According to the launchd docs, ...To load the helper immediately ... the alternative possibly involves a script to call launchctl Well, I wouldn't call it an alternative. I believe it is the only way to do it. If anyone knows a better way, please let us know. but how would this work Unfortunately, it looks like a job for NSTask. Try the function SSYLoadLaunchdJob given below and let me know if it works. I'll need to do the same thing soon. and more importantly, how would it be integrated into the PrefPane code? Insert the call to SSYLoadLaunchctlJob() any time after you have written your plist file. the sporadic comments google turned up on the subject say it's not worth the trouble. I'd like to read those comments if you could find the links in your browser history. // *** Declarations with HeaderDoc comments /*! @function SSYLoadLaunchdJob @abstract Invokes the system's launchctl command to load a launchd job @discussion This function blocks until the task completes. @param plistPath The full path to the .plist file defining the job, in one of the LaunchAgents directories. @result The result of the launchctl command which was returned by the system */ int SSYLoadLaunchdJob(NSString* plistPath) ; /*! @function SSYDoShellTask() @abstract A wrapper around NSTask to launch a command-line process @discussion Only use this function after you have searched far and wide for a Cocoa, CoreFoundation, Carbon, or any built-in API to do what you want to do. That is because this function will spawn another process which often leads to trouble. Use it sparingly. Examine the return value, stdOut_p and stdErr_p and write code to recover from errors. @param command The command, not including its arguments. A full path to the desired tool is recommended. Example: @/bin/launchctl @param arguments The array of arguments which should be passed with the command. Each element of the array should be an NSString, one of the space-separated words that you would type on the command line if you were performing this task via Terminal.app. For example, to perform the task /bin/launchctl -load /Users/me/LaunchAgents/MyTask.plist The 'command' would be @/bin/launchctl/ and the 'arguments' would be an array of two strings, @-load and @/Users/me/LaunchAgents/MyTask.plist in that order. If the command does not use a space between its argument letter and its text, for example - oPath/To/Output, this would be entered as a single string element in 'arguments'. If the command has no arguments, pass nil. Arguments can be very tricky. For example, I have never found a way to pass in pipe redirects. I tried this suggestion once: http://www.cocoabuilder.com/archive/message/cocoa/2005/2/24/129019 but could not get it to work. @param inDirectory The working directory in which the command will be launched. You may pass nil. In that case, the tasks's current directory is inherited from this process, which, for applications, appears to be the root level of the startup drive. Run command pwd if you need to be sure. To avoid problems, I'd say never pass inDirectory = nil unless you're giving a full path in 'command'. @param stdInData The stdin data to be passed to the command. If nil, the tasks's standard input is inherited from this process. I suppose that could be interesting. @param stdOutData_p If you want the stdout from the task, pass an NSData*. On output it will point to an NSData object containing the stdout. Otherwise, pass NULL. In that case the stdout location is inherited from the calling process and will not be returned. @param stdErrData_p If you want the stderr from the task, pass an NSData*. On output it will point to an NSData object containing the stderr. Otherwise, pass NULL. In that case the stderr location is inherited from the calling process and will not be returned. @param waitUntilExit If YES, this function blocks until the task completes or aborts and exits. If NO, this function will return immediately. @result If waitUntilExit is YES, returns whatever the task returns. If waitUntilExit is NO, returns -999. */ int SSYDoShellTask(NSString* command, NSArray* arguments, NSString* inDirectory, NSData* stdInData, NSData** stdOutData_p, NSData** stdErrData_p, BOOL waitUntilExit) ; // *** Implementations int SSYLoadLaunchdJob(NSString* plistPath) { NSArray* arguments = [NSArray arrayWithObjects:@load, plistPath, nil] ; return SSYDoShellTask(@/bin/launchctl/, arguments, nil,
IBAction deselects currently selected Core Data record?
I have a Core Data application with a subclass of NSManagedObject. The subclass has an IBAction that, when triggered, needs to get the value of several entity properties of the currently selected record. I have the accessor methods declared properly in the declaration and implementation files, and they work fine from within other parts of the code, but when executing something like this: - (IBAction)exportData:(id)sender { NSString *theData = [self projectName]; } the running application errors out, and the value of projectName is nil. What am I missing? TIA, - Mike --- Michael A. LaMorte In matters of style, swim with the current; In matters of principle, stand like a rock -Thomas Jefferson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
How to get Safari Bookmarks in the code
Hi All, I am creating a application that needs to display Safari Bookmarks. Is there any way to get safari bookmarks. Please help me in this.. Regards, Sridhar. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSManagedObject custom class for loop
Hi folks, In my core data app I have an Account entity. I've subclassed this as I want to add a method that calculates the Account's balance by doing a fetch on Transaction entities and tallying up the amounts. I've created a custom class in xcode and added the following code in Account.m #import Account.h @implementation Account @dynamic name; @dynamic envelopeVisible; @dynamic accounts; @dynamic out; @dynamic type; @dynamic in; @dynamic envelope; //custom stuff - (NSNumber *)balance { // we fetch all the transactions our account is related to and tally up the balance NSNumber *balance; NSManagedObjectContext *moc = [self managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@Transaction inManagedObjectContext:moc]; [request setEntity:entity]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@toAccount = %@, self]; [request setPredicate:predicate]; NSError *error = nil; NSArray *transactions = [moc executeFetchRequest:request error:error]; if (transactions == nil){ NSLog(@Account balance fetch returned nil); } NSLog(@Account balance for %@ counted %d transactions,[self name], [transactions count]); //iterate through transactions and tally balance NSManagedObject *transaction; for (transaction in transactions){ NSNumber *amount = [entity amount]; balance = [NSNumber numberWithFloat:[balance floatValue] - [amount floatValue]]; } return balance; } @end The problem is when the code hits the for (transaction in transactions) loop it dumps to GDB with an obj_msgsend error and I can't see why. Am I trying to do something that a custom class shouldn't be able to do? If I comment out the loop it runs fine. In the first line of your loop you're sending the -amount message to the entity, not the transaction object. That line should probably read NSNumber *amount = [transaction amount] A few other things though, with more than a few transactions this will be really slow. You could request the sum of the transaction amounts directly from CoreData and it could handle them much quicker. Something like [account valueForKeyPath:@[EMAIL PROTECTED]] assuming you've set up a transactions relationship. If you don't have a relationship you could still perform your fetch and issue a similar message to the transactions array you get here, [transactions valueForKeyPath:@@sum.amount] If, for some reason, you still need to iterate over all of the objects individually, I'd recommend that you don't convert your final balance to an NSNumber until you're finished with your loop. Ashley Clark ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSTokenField Drag and Drop
On Sep 28, 2008, at 6:57 PM, Chris Idou wrote: However, when I drag a token (Token) from the palette to the field, it arrives as a string and not a token. tokenField:(NSTokenField *)tokenField styleForRepresentedObject:(id)representedObject gets called with a NSString and not a Token class. I read somewhere you need to implement - (void)encodeWithCoder:(NSCoder *)encoder and - (id)initWithCoder: (NSCoder *)decoder on your Token, which I did, but they don't seem to get called. Has anyone got any tips or example code? When I ran into this problem, I ended up solving it by subclassing NSTokenField and overriding -performDragOperation: to call - tokenField:readFromPasteboard:, which apparently the default implementation doesn't do when dragging, and from there insert the token and send out the did-change notification. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to get Safari Bookmarks in the code
On Sep 29, 2008, at 7:39 AM, SridharRao M wrote: I am creating a application that needs to display Safari Bookmarks. Is there any way to get safari bookmarks. Two ways I know of: Read the Bookmarks.plist file using NSDictionary, or use Sync Services to synchronize the bookmarks. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Two questions about cocoa programming...
On Sep 28, 2008, at 9:44 AM, Leopard x86 wrote: Hi everyone. In the recent development, I need to solve the following two issues: In the future, if you have multiple questions, please post each one in a separate message. Furthermore, please use more descriptive subject lines. Everybody is asking questions about Cocoa programming, that's what this list is for. -- Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Menu item issues when programmatically updating an application's main menu
On Wed, Sep 24, 2008 at 02:32, Kyle Sluder [EMAIL PROTECTED] wrote: Your best bet might be to file a bug report at http://bugreport.apple.com . Done, see rdar://problem/6253819. Thanks Mattias ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Mouse events with higher priority then repeating NSTimer
It seems my problem was that I was putting as interval 1/10 not 0.1 or 1.0/10, this presumebly was as putting interval 0. That's why the continuous loop :) Thanks, chr On Mon, Sep 29, 2008 at 11:22 AM, Christian Giordano [EMAIL PROTECTED] wrote: Hi guys, I'm trying to render the stage with a default interval. When the needed time to render the scene is higher than the interval itself, the application doesn't process anymore the mouse events. I'm setting the timer once with [NSTimer scheduledTimerWithTimeInterval]. I'm thinking of recreating a not repeating timer every time it fires, but I'm wondered if there is a better way. Is there any other way you would recommend to have a continuous rendering without making the app not reactive? Thanks, chr ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
More on Keyboard Event posting
Hi everyone, I eventually figured out my previous problem with keyboard event posting when a colleague of mine pointed out the CGPostKeyboardEvent had been deprecated. After digging around some more, we came up with the following: [window makeFirstResponder:textfield]; CGEventSourceRef sourceRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); if (sourceRef == nil) { return; } //40 = k CGEventRef eventDown = CGEventCreateKeyboardEvent(sourceRef, 40, true); CGEventSetFlags(eventDown, kCGEventFlagMaskAlternate +kCGEventFlagMaskShift); CGEventRef eventUp = CGEventCreateKeyboardEvent(sourceRef, 40, false); CGEventPost(kCGAnnotatedSessionEventTap, eventDown); CGEventPost(kCGAnnotatedSessionEventTap, eventUp); CFRelease(eventDown); CFRelease(eventUp); CFRelease(sourceRef); Running that code will correctly produce an apple symbol in the TextField. Other local commands that we send (Command-A, Command-C, Command-Q, etc) all work correctly. Even shortcuts for Services work. However some keyevents, such as Command-Space to activate Quicksilver on my machine (usually Spotlight) or Shift-Command-3 to take a screenshot or Command-Tab to activate the application switcher, only produce a system beep. Any ideas why and how we can get around that? We thought it might be the event source state used to create the CGEventSourceRef, but changing it to kCGEventSourceStateHIDSystemState or even kCGEventSourceStatePrivate did not produce the desired results. Any direction would be appreciated. Thanks, Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: problems in runModal in NSOpenPanel used with defaults
On Sep 26, 2008, at 10:34 PM, spartan g wrote: Thanks Corbin, I have used your tips in the updated code. Besides, my aim is to save the filename selected through the panel to a pList file timely whenever it is changed, so I am using synchronization of defaults. I checked and found that there is no resetStandardUserDefaults used anywhere in the entire project. I tried implementing dictionary insted of defaults and updating the pList contents accordingly. But to my surprise, in either cases(dictionary/defaults), whenever I click browse and click cancel/open the junk values are appended automatically in the pList file!!! For the time being I am deleting and recreating the file, but it doesn't seem a good alternative!!! How can a 'Panel runModal' add such junk in the pList!!! Michael already clarified a bit, but it sounds like your definition of junk isn't what I had expected. I assumed you were reading in bad (unexpected) values, ie: junk. But I think you are referring to the other values the save panel places there. As michael said, this is just the way it works. Consider using NSDictionary and writeToFile:... instead corbin Sparta... On Fri, Sep 26, 2008 at 10:48 PM, Corbin Dunn [EMAIL PROTECTED] wrote: Howdy spartan, Oh! A few little tips: On Sep 26, 2008, at 3:11 AM, spartan g wrote: Hi, I am writing an utility which needs to open a panel to browse files and select one. - (IBAction)browseClicked:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; if ([panel runModal]) { NSArray *filenames = [panel filenames]; NSString *filename = [filenames objectAtIndex:0]; Always check the array length first, or just use [panel filename]; if (filename){ printf(\n browseClicked: filename = %s \n, [filename cString]); Just a side note: most cocoa people move to NSLog, but printf still works. Try: NSLog(@%@, filename); -- much easier! if ([appToOpenText stringValue] != NULL ){ nil is preferred to NULL. [appToOpenText setStringValue: filename]; } else printf(\n browseClicked: appToOpenText has NULL value \n); } else printf (\n *** browseClicked: Filename is NULL *** \n); } } The filename chosen is assigned to the textfield. I have used defaults to synchronize this filename and storing it in a pList file. [_defaults setObject: [appToOpenText stringValue] forKey: @AppToOpen ]; It seems strange to use the user defaults as your model to store objects, but i'm sure there is a reason you do this. [_defaults synchronize]; You probably don't want to hold onto the userdefaults instance as an ivar, and instead always query it with [NSUserDefaults standardUserDefaults]. It may be possible that something is calling resetStandardUserDefaults, and blowing away the old instance. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Making NSTableView column headers editable
On Sep 28, 2008, at 2:00 AM, Andrew BusH wrote: Hi all, What is the best approach to do this? I would like the user to be able to double click on the header cell of a NSTableView and have a field appear in place that would let them change the heading. Ive tried just setting [[NSTableColumn headercell setEditable:YES] when I create the column, but that (unsurprisingly) isn't working. This would involve subclassing of the header cell to override mouse tracking and editing. It wouldn't be impossible to do, but the UI would be strange. You may want to consider another way of allowing the users to change the names. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: IBAction deselects currently selected Core Data record?
On Sep 28, 2008, at 16:21, Michael LaMorte wrote: I have a Core Data application with a subclass of NSManagedObject. The subclass has an IBAction that, when triggered, needs to get the value of several entity properties of the currently selected record. I have the accessor methods declared properly in the declaration and implementation files, and they work fine from within other parts of the code, but when executing something like this: - (IBAction)exportData:(id)sender { NSString *theData = [self projectName]; } the running application errors out, and the value of projectName is nil. What kind of error, and where precisely does it occur? Are there any error messages in the log? On the face of it, there is something wrong with your code design here. A managed object is almost certainly part of your data model. An object that executes IBActions is almost certainly a controller. So, an IBAction in a managed object is ordinarily a no-no. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Two questions about cocoa programming...
On 29 Sep 2008, at 2:44 am, Leopard x86 wrote: 2. Using openPanel function: how can we memorize the most recent opened directory? As the question says, we often the open panel directive to open file, is there some method to guarantee that we can be the same location which is opened last time? By default, the panel always opens at the same directory it was last set to. If however, you mean remember this between launches of your app, then just save the path returned by the panel, stripping off the last path element, then pass this back in the path: parameter of - beginForDirectory:, etc. The same applies if you use the open panel in several places and want each use to set a different directory depending on the context in your app. hth, Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Mouse events with higher priority then repeating NSTimer
On Mon, Sep 29, 2008 at 11:08 AM, Christian Giordano [EMAIL PROTECTED] wrote: It seems my problem was that I was putting as interval 1/10 not 0.1 or 1.0/10, this presumebly was as putting interval 0. That's why the continuous loop :) Indeed, welcome to the wonderful world of C. 1/10 is zero. 1/2 * 3 is zero. The fun never ends! Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to develop a Safari event listener
Hi Bill Unless things have changed recently, what you're looking for is called Not Officially Supported by Safari. As you discovered, there is no interface that will allow a plugin to load arbitrarily unless it's going to provide some sort of media handler for content on the page. That being said, the WebKit plugin API *can* do what you want, but it's a bit ugly at best and utilizes a loophole in how plugins can externally define their MIME types to get the plugin to load. If you search Google for Safari and browser with plugins, you'll find some guidance. Finally, if you're completely open to all options, things like SIMBL or Unsanity's Application Enhancer may be an option... but input managers can get people's feathers ruffled. Plus, there could be a large discussion on whether input managers will be around much longer at all (which I won't start here). In short, use them at your own risk. -- Jim http://nukethemfromorbit.com On Sun, Sep 28, 2008 at 8:43 PM, Bill Morgan [EMAIL PROTECTED] wrote: Hi to all, I am trying to develop a small tool, it can be an appliction/bundle/plug-in ... The goal is, when Safari opens certain web page, like www.apple.com, the tool will be launched automatically, and it can get the page's url. I know for firefox, people call this kind of tool as add-on, not sure what it's exactly called for Safari. I tried to do it with Web Kit plug-in. But as I learned, Web Kit plug-in only works when the web page has certain embed tag, like 'mov', that was defined in the MIME type that the plug-in registered for. But in my case, I want the tool to work for any web page Safari opened. Any one has any suggestion on how to do this? thank you all for your kind support! Bill ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jturner.lists%40gmail.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to get Safari Bookmarks in the code
You could look into the bookmarks portion of our imedia framework: http://code.google.com/p/imedia/ Mike. On 29 Sep 2008, at 14:39, SridharRao M wrote: Hi All, I am creating a application that needs to display Safari Bookmarks. Is there any way to get safari bookmarks. Please help me in this.. Regards, Sridhar. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to count composed characters in NSString?
On Sep 28, 2008, at 11:17 AM, David Niemeijer wrote: I need to be able to display the number of characters to the user in a way that makes sense to them. If they see 3 I should report 3. I also need it to cut-off certain input to the number of real characters and should not generate results that only make sense for a language like English where each 16 bits equals a single character. What you are describing is the notion that Unicode sometimes refers to as a user-perceived character, which in general can be somewhat ambiguous, since different users may have different perceptions, and since there are writing systems in which character boundaries are not at all similar to those in English. To handle this sort of issue programmatically, Unicode defines what are known as grapheme clusters, but there is not a single notion of grapheme cluster; there are several such notions, depending on precisely what it is you want. These issues are covered in detail in Unicode Standard Annex #29, http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries , which gives a number of examples and some algorithms for determining grapheme cluster boundaries. Grapheme clusters are similar to but not quite identical to composed character sequences. For some purposes composed character sequences may be sufficient; NSString gives prominence to the notion of composed character sequence, because that is the most important concept for arbitrary text processing, but if you are really interested in user-perceived characters you may wish to use something else. The most problematic scripts for this sort of determination include: handwriting-based scripts such as Arabic, in which (depending on the ligatures used in a particular font) character boundaries may not be readily perceptible; composed scripts such as Hangul, in which the script elements are in turn composed of smaller, individually meaningful graphic elements; and scripts involving reordering and combining, such as Devanagari and other Indic or Indic-influenced scripts. There is still another similar but not quite identical notion, which is used for determining the number and position of insertion points during editing. In Leopard, NSLayoutManager has API support for determining insertion point positions within a line of text as it is laid out. Note that insertion point boundaries are not identical to glyph boundaries; a ligature glyph in some cases, such as an fi ligature in Latin script, may require an internal insertion point on a user-perceived character boundary. Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to get Safari Bookmarks in the code
On Sep 29, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote: Subject: How to get Safari Bookmarks in the code To: [EMAIL PROTECTED], cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 Hi All, I am creating a application that needs to display Safari Bookmarks. Is there any way to get safari bookmarks. Please help me in this.. Regards, Sridhar. Lots of ways to do this. You the bookmarks plist file is specific to each user's library. That's the thing to read. You could read it using almost anything. It is a very very simple list of bookmarks. You could use applescript to export the bookmarks from safari. This yields the bookmarks in an html file. Your options are many and flexible. You might want to play with it a bit more first. It's pretty trivial data to access. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Tracking area pending install and disabled
I create a NSTracking area with tkarea = [[NSTrackingArea alloc] initWithRect:usedrect options:NSTrackingMouseEnteredAndExited |NSTrackingActiveInActiveApp owner:self userInfo:nil]; [self addTrackingArea:tkarea]; 1) the owner is self - an instance of a subclass of NSTextView 2) the usedrect has been intersected with [self bounds] The mouseEntered and mouseExited methods are not called. If I display the tracking area with NSLog after adding the trackingArea to the view, I get the following display: 2008-09-29 11:01:59.803 task[656:813] - trackingArea = NSTrackingArea 0x17a910: rect={{0, 0}, {566, 28}}, owner=0x853000 userData=(null) NSTrackingMouseEnteredAndExited NSTrackingActiveInActiveApp pendingInstall notInstalled disabled I believe that I had this problem before, and resolved it, but I seem to be running on half memory, and can't recall what the solution was. In fact, the code I'm using now is an almost literal copy of the code in the old project, which works properly. The code also seems to be consistent with code in the Cocoa Event Handling Guide and previous discussions on this list. Searching for NSTrackingArea and either pendingInstall, notInstalled or disabled was not fruitful. Any Suggestions? Regards, Dale Miller [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Crash with toolbars
On Sep 28, 2008, at 4:20 PM, Felipe Monteiro de Carvalho wrote: Hello, I am having a problem with toolbars. I have created a delegate class for my toolbar, but when I added the toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: method it crashes: Exception: EXC_BREAKPOINT (0x0006) Code[0]:0x0002 Code[1]:0x Thread 0 Crashed: 0 com.apple.Foundation0x9282a45f _NSRaiseError + 227 1 com.apple.Foundation 0x92851247 +[NSException raise:format:] + 57 2 com.apple.Foundation 0x9285108c _NSArrayRaiseInsertNilException + 75 3 com.apple.Foundation 0x927f47fc -[NSCFArray insertObject:atIndex:] + 125 4 com.apple.AppKit0x933c5279 -[NSToolbar _forceInsertItem:atIndex:] + 364 5 com.apple.AppKit0x933c4df2 -[NSToolbar _insertNewItemWithItemIdentifier:atIndex:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults :] + 152 It looks like your delegate method is returning nil. You can't return nil from itemForItemIdentifier:. I suppose that the bool used in the routine will be mapped to a long, is that it? What is the adequate type encoding for a bool in Objective-C? The docs says nothing about this. BOOLs are signed char. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Problem setting the menu
On Sep 28, 2008, at 4:15 PM, Felipe Monteiro de Carvalho wrote: Hello, I am having problems setting a menu for my application. I am writting the application in Object Pascal and I am not using nib files, because the point is being able to use this to port cross-platform GUI libraries. NSMenu needs a minimal nib to properly set up the application menu. You can construct your other menus programmatically however. I create a NSMenu and set it to both AppleMenu and MainMenu, or just 1 of them, but nothing happens!! I always get just an empty menu. I have read tutorials out there, but according to them this code should work. The main menu contains some items, and those items have submenus, and the titles of those submenus are what appear in the menu bar. Your main menu items do not have any submenus, which is why you're not seeing anything in the menu bar. If you give the menu item a submenu, you'll see it in the menu bar. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Resize Indicator on a NSPanel
Can one programmatically control the size of the resize indicator on a NSPanel? If so, how? Is it possible to programmatically get or compute the frame the resize indicator occupies on a NSPanel? thank you. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Problem in using NSKeyedUnarchiver for my custom class
Hi, I am trying to write instances of a class (subclass of NSObject) in an array and then write them to a preferences files using NSKeyedArchiver. It does so successfully. After i unarchive it using NSKeyedUnarchiver, it reads the contents in the array. It also reports correct no. of objects of that class in the array. But when i try to use those objects, program crashes. To check the program, i did this with simple NSArray instances instead of my class objects. It worked fine. So i have my doubts on my class. Any ideas why i have done wrong in my class. Here is the code of my class. data.h @interface data : NSObject NSCoding{ NSNumber *height; NSString *name; } -(NSNumber *)height; -(void)setHeight:(NSNumber *)aNumber; -(NSString *)name; -(void)setName:(NSString *)aString; -(void)initWithParams:(float)aFloat name:(NSString *)aString; -(void)dealloc; -(id)initWithCoder:(NSCoder*)coder; -(void)encodeWithCoder:(NSCoder*)coder; data.m @implementation data -(void)initWithParams:(float)aFloat name:(NSString *)aString { [super init]; height = [NSNumber numberWithFloat:aFloat]; name = [NSString stringWithString:aString]; } -(void)setHeight:(NSNumber *)aNumber { if(height != aNumber) { [height autorelease]; height = [NSNumber numberWithFloat:[aNumber floatValue]]; } } -(NSNumber *)height { return height; } -(void)setName:(NSString *)aString { if(name != aString) { [name autorelease]; name = [NSString stringWithString:aString]; } } -(NSString *)name { return name; } -(id)initWithCoder:(NSCoder*)coder { if(self = [super init]) { [self setHeight:[coder decodeObjectForKey:@Height]]; [self setName:[coder decodeObjectForKey:@Preset Name]]; } return self; } -(void)encodeWithCoder:(NSCoder*)coder { [coder encodeObject:height forKey:@Height]; [coder encodeObject:name forKey:@Preset Name]; } -(void)dealloc { [super dealloc]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Problem in using NSKeyedUnarchiver for my custom class
name = [NSString stringWithString:aString]; is creating an autoreleased string. If you want to keep it around, you will need to: [name retain]; and similarly with your height setter. I believe this will solve your problem. Can you use or are you using Obj-C 2.0? If so, I would suggest looking into using @property @synthesize. You could define your height name by doing: @property (retain) NSNumber *height; @property (retain) NSString *name; and in your implementation so: @synthesize height; @synthesize name; With this, you can get rid of your getter setter code. On Sep 29, 2008, at 4:57 PM, Adil Saleem wrote: Hi, I am trying to write instances of a class (subclass of NSObject) in an array and then write them to a preferences files using NSKeyedArchiver. It does so successfully. After i unarchive it using NSKeyedUnarchiver, it reads the contents in the array. It also reports correct no. of objects of that class in the array. But when i try to use those objects, program crashes. To check the program, i did this with simple NSArray instances instead of my class objects. It worked fine. So i have my doubts on my class. Any ideas why i have done wrong in my class. Here is the code of my class. data.h @interface data : NSObject NSCoding{ NSNumber *height; NSString *name; } -(NSNumber *)height; -(void)setHeight:(NSNumber *)aNumber; -(NSString *)name; -(void)setName:(NSString *)aString; -(void)initWithParams:(float)aFloat name:(NSString *)aString; -(void)dealloc; -(id)initWithCoder:(NSCoder*)coder; -(void)encodeWithCoder:(NSCoder*)coder; data.m @implementation data -(void)initWithParams:(float)aFloat name:(NSString *)aString { [super init]; height = [NSNumber numberWithFloat:aFloat]; name = [NSString stringWithString:aString]; } -(void)setHeight:(NSNumber *)aNumber { if(height != aNumber) { [height autorelease]; height = [NSNumber numberWithFloat:[aNumber floatValue]]; } } -(NSNumber *)height { return height; } -(void)setName:(NSString *)aString { if(name != aString) { [name autorelease]; name = [NSString stringWithString:aString]; } } -(NSString *)name { return name; } -(id)initWithCoder:(NSCoder*)coder { if(self = [super init]) { [self setHeight:[coder decodeObjectForKey:@Height]]; [self setName:[coder decodeObjectForKey:@Preset Name]]; } return self; } -(void)encodeWithCoder:(NSCoder*)coder { [coder encodeObject:height forKey:@Height]; [coder encodeObject:name forKey:@Preset Name]; } -(void)dealloc { [super dealloc]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: More on Keyboard Event posting
On Sep 29, 2008, at 10:25 AM, Dave DeLong wrote: However some keyevents, such as Command-Space to activate Quicksilver on my machine (usually Spotlight) or Shift-Command-3 to take a screenshot or Command-Tab to activate the application switcher, only produce a system beep. Any ideas why and how we can get around that? We thought it might be the event source state used to create the CGEventSourceRef, but changing it to kCGEventSourceStateHIDSystemState or even kCGEventSourceStatePrivate did not produce the desired results. I think the problem is the event tap point at which you're inserting the event. Instead of kCGAnnotatedSessionEventTap, try kCGSessionEventTap or kCGHIDEventTap. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: More on Keyboard Event posting
Rock on! Changing that eventTap to kCGHIDEventTap worked perfectly! Thank you so much! Dave On Sep 29, 2008, at 4:16 PM, Ken Thomases wrote: On Sep 29, 2008, at 10:25 AM, Dave DeLong wrote: However some keyevents, such as Command-Space to activate Quicksilver on my machine (usually Spotlight) or Shift-Command-3 to take a screenshot or Command-Tab to activate the application switcher, only produce a system beep. Any ideas why and how we can get around that? We thought it might be the event source state used to create the CGEventSourceRef, but changing it to kCGEventSourceStateHIDSystemState or even kCGEventSourceStatePrivate did not produce the desired results. I think the problem is the event tap point at which you're inserting the event. Instead of kCGAnnotatedSessionEventTap, try kCGSessionEventTap or kCGHIDEventTap. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Passing focus to a control
I have a window of controls, a NSComboBox and some NSTextFields. I want to be able to place the cursor in the NSComboBox when the user selects Cmd-J. All of the code for managing the window is in an .h and .m file: @interface HF_Browser : NSDocument { ... When I press Cmd-J I get my function called but can't work out how to get the control to get the focus. I've tried becomeFirstResponder but nothing happens and no error occurs. Please help! I'm sure this is an obvious error, but after 3 hours I still can't get it working for me :-/ -- Paul Harvey Lead Programmer [EMAIL PROTECTED] Hiddenfield Software Creating useful software for Mac OS X www.hiddenfield.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Load launchd job immediately, without restart - how?
(Oops, hit reply and forgot to change the address to cocoa-dev) Thanks for the tip! This looks like what I had in mind, I'll give it a spin. Regarding the original route I mentioned, there is a programmatic way to interface directly with launchd. Look in /usr/include/launch.h; there's also some Apple sample code (http://developer.apple.com/samplecode/SampleD/ ). However, after looking through the header and the sample, it seems like an awful lot of trouble - and code - for such a minor task (loading/unloading a job). I find it very strange that it is so easy to register a launchd job, yet so difficult to actually load it. As an aside, I found Lingon (http://lingon.sourceforge.net/) to be extremely useful when working with launchd plists. D. Roilidis On Sep 29, 2008, at 2:58 PM, Jerry Krinock wrote: On 2008 Sep, 28, at 7:49, Dimitris Roilidis wrote: I have a PrefPane that acts as a ui for a command line utility (helper). According to the launchd docs, ...To load the helper immediately ... the alternative possibly involves a script to call launchctl Well, I wouldn't call it an alternative. I believe it is the only way to do it. If anyone knows a better way, please let us know. but how would this work Unfortunately, it looks like a job for NSTask. Try the function SSYLoadLaunchdJob given below and let me know if it works. I'll need to do the same thing soon. and more importantly, how would it be integrated into the PrefPane code? Insert the call to SSYLoadLaunchctlJob() any time after you have written your plist file. the sporadic comments google turned up on the subject say it's not worth the trouble. I'd like to read those comments if you could find the links in your browser history. // *** Declarations with HeaderDoc comments /*! @function SSYLoadLaunchdJob @abstract Invokes the system's launchctl command to load a launchd job @discussion This function blocks until the task completes. @param plistPath The full path to the .plist file defining the job, in one of the LaunchAgents directories. @result The result of the launchctl command which was returned by the system */ int SSYLoadLaunchdJob(NSString* plistPath) ; /*! @function SSYDoShellTask() @abstract A wrapper around NSTask to launch a command-line process @discussion Only use this function after you have searched far and wide for a Cocoa, CoreFoundation, Carbon, or any built-in API to do what you want to do. That is because this function will spawn another process which often leads to trouble. Use it sparingly. Examine the return value, stdOut_p and stdErr_p and write code to recover from errors. @param command The command, not including its arguments. A full path to the desired tool is recommended. Example: @/bin/launchctl @param arguments The array of arguments which should be passed with the command. Each element of the array should be an NSString, one of the space-separated words that you would type on the command line if you were performing this task via Terminal.app. For example, to perform the task /bin/launchctl -load /Users/me/LaunchAgents/MyTask.plist The 'command' would be @/bin/launchctl/ and the 'arguments' would be an array of two strings, @-load and @/Users/me/LaunchAgents/MyTask.plist in that order. If the command does not use a space between its argument letter and its text, for example - oPath/To/Output, this would be entered as a single string element in 'arguments'. If the command has no arguments, pass nil. Arguments can be very tricky. For example, I have never found a way to pass in pipe redirects. I tried this suggestion once: http://www.cocoabuilder.com/archive/message/cocoa/2005/2/24/129019 but could not get it to work. @param inDirectory The working directory in which the command will be launched. You may pass nil. In that case, the tasks's current directory is inherited from this process, which, for applications, appears to be the root level of the startup drive. Run command pwd if you need to be sure. To avoid problems, I'd say never pass inDirectory = nil unless you're giving a full path in 'command'. @param stdInData The stdin data to be passed to the command. If nil, the tasks's standard input is inherited from this process. I suppose that could be interesting. @param stdOutData_p If you want the stdout from the task, pass an NSData*. On output it will point to an NSData object containing the stdout. Otherwise, pass NULL. In that case the stdout location is inherited from the calling process and will not be returned. @param stdErrData_p If you want the stderr from the task, pass an NSData*. On output it will point to an NSData object containing the stderr. Otherwise, pass NULL. In that case the stderr location is inherited from the calling process and will not be returned. @param waitUntilExit
Window Shadow
Hi all, I have a problem with shadows on transparent windows: I create a fullscreen borderless transparent window with a view (an object derived from NSView) in the center and I don't want to have a shadow on it. [self setBackgroundColor: [[NSColor blueColor] colorWithAlphaComponent:0.0]]; [self setAlphaValue:1.0]; [self setOpaque:NO]; [self setHasShadow:NO]; (self = myWindow) When I launch my application, all is ok (ther isn't shadow); but if I go to another virtual desktop (I use 'Spaces' from Mac OSX ), when I come back to the first screen, my view has a shadow. Do you have an idea (maybe it's a Mac OS bug...)? Regards Matthieu ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSWindow animationResizeTime
Is there any way to alter the value provided by animationResizeTime without subclassing NSWindow (as the documentation suggests)? Thanks, -Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Newbie: Strange problem with NSTableView, check boxes and Core Data
Hi all, I'm new on this list -- teaching myself Cocoa programming by writing a small utility as a Core Data document-based application. Mostly I have everything working well, but there is one strange bug I can't isolate where a check box in a table view sometimes fails to draw itself properly. This happens maybe one time out of ten. Details: - I have a Core Data entity with properties Name (a string) and Enabled (a bool). Both are non-optional and have default values New and YES, respectively. - In my document NIB file I have an array controller set to manage that entity. It is set to prepare content and editable. - also in the NIB, a table view with two columns: one of checkboxes, bound to the Enabled property through the array controller, and one of text fields bound to the Name - an IBAction method, linked to a new button, which creates a new instance of the entity with the NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: method - This is a garbage-collected project. The new document is created with no instances of the entity. When clicking the new button, 9 times out of 10 everything seems fine. When it goes wrong, either the checkbox for the newly inserted entity doesn't draw at all, or it lacks the checkmark or the highlight or some other visual element. There is a console message like: 2008-09-29 11:32:56.955 IU Organ Utility v2[12568:10b] *** - [CIFilterClassDescription _feImage]: unrecognized selector sent to instance 0x10d32a0 2008-09-29 11:32:56.956 IU Organ Utility v2[12568:10b] Exception *** - [CIFilterClassDescription _feImage]: unrecognized selector sent to instance 0x10d32a0 Sometimes the class is _NSCFNumber or CIFilterShape instead of CIFilterClassDescription. Sometimes there's no message, but the app crashes with an EXC_BAD_ACCESS; and sometimes there's instead a message about free() which says something about a reference count underrun (sorry, I've been trying to repeat it while writing this and haven't managed to). Anyone have any ideas? It seems a little similar to the [NSCFNumber intValue]: unrecognized selector problem recently discussed here, but I'm not explicitly using any threads in this app. It almost seems like something is getting freed by the garbage collector before it's used. Thanks for any advice about a newbie's problem, Jonathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Window Shadow
On Sep 29, 2008, at 10:55 AM, Matthieu Campion wrote: When I launch my application, all is ok (ther isn't shadow); but if I go to another virtual desktop (I use 'Spaces' from Mac OSX ), when I come back to the first screen, my view has a shadow. Do you have an idea (maybe it's a Mac OS bug...)? If it's not a bug, it's a misbehavior. I don't think there's any reason to expect this to happen, so I'd file it as a bug: http://bugreport.apple.com/ -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Passing focus to a control
On Sep 29, 2008, at 2:36 AM, Cocoader wrote: When I press Cmd-J I get my function called but can't work out how to get the control to get the focus. I've tried becomeFirstResponder but nothing happens and no error occurs. Please help! I'm sure this is an obvious error, but after 3 hours I still can't get it working for me :-/ The method you're looking for is -[NSWindow makeFirstResponder:], not - becomeFirstResponder. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Passing focus to a control
Directly quoting the -becomeFirstResponder: docs: Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly. Also, it's called a method, not a function. On 29 Sep 2008, at 09:36, Cocoader wrote: I have a window of controls, a NSComboBox and some NSTextFields. I want to be able to place the cursor in the NSComboBox when the user selects Cmd-J. All of the code for managing the window is in an .h and .m file: @interface HF_Browser : NSDocument { ... When I press Cmd-J I get my function called but can't work out how to get the control to get the focus. I've tried becomeFirstResponder but nothing happens and no error occurs. Please help! I'm sure this is an obvious error, but after 3 hours I still can't get it working for me :-/ -- Paul Harvey Lead Programmer [EMAIL PROTECTED] Hiddenfield Software Creating useful software for Mac OS X www.hiddenfield.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/cocoadev%40mikeabdullah.net This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Load launchd job immediately, without restart - how?
OK I checked and tested the code, and it seems to work just fine. Had to make a few minor tweaks 'cause of compiler warnings, and also added the -unload command, but otherwise, it's just what I needed. Many thanks! Now all I need is to determine what happens if the PrefPane is deleted without having a chance to unload and delete the plist. Hate leaving garbage behind... Thanks again D. Roilidis On Sep 29, 2008, at 4:23 PM, Dimitris Roilidis wrote: (Oops, hit reply and forgot to change the address to cocoa-dev) Thanks for the tip! This looks like what I had in mind, I'll give it a spin. Regarding the original route I mentioned, there is a programmatic way to interface directly with launchd. Look in /usr/include/ launch.h; there's also some Apple sample code (http://developer.apple.com/samplecode/SampleD/ ). However, after looking through the header and the sample, it seems like an awful lot of trouble - and code - for such a minor task (loading/unloading a job). I find it very strange that it is so easy to register a launchd job, yet so difficult to actually load it. As an aside, I found Lingon (http://lingon.sourceforge.net/) to be extremely useful when working with launchd plists. D. Roilidis On Sep 29, 2008, at 2:58 PM, Jerry Krinock wrote: On 2008 Sep, 28, at 7:49, Dimitris Roilidis wrote: I have a PrefPane that acts as a ui for a command line utility (helper). According to the launchd docs, ...To load the helper immediately ... the alternative possibly involves a script to call launchctl Well, I wouldn't call it an alternative. I believe it is the only way to do it. If anyone knows a better way, please let us know. but how would this work Unfortunately, it looks like a job for NSTask. Try the function SSYLoadLaunchdJob given below and let me know if it works. I'll need to do the same thing soon. and more importantly, how would it be integrated into the PrefPane code? Insert the call to SSYLoadLaunchctlJob() any time after you have written your plist file. the sporadic comments google turned up on the subject say it's not worth the trouble. I'd like to read those comments if you could find the links in your browser history. [...] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/roilidis%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/roilidis%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Newbie: Strange problem with NSTableView, check boxes and Core Data
On Sep 29, 2008, at 10:55 AM, Jonathan Oddie wrote: Hi all, I'm new on this list -- teaching myself Cocoa programming by writing a small utility as a Core Data document-based application. Mostly I have everything working well, but there is one strange bug I can't isolate where a check box in a table view sometimes fails to draw itself properly. This happens maybe one time out of ten. Details: - I have a Core Data entity with properties Name (a string) and Enabled (a bool). Both are non-optional and have default values New and YES, respectively. - In my document NIB file I have an array controller set to manage that entity. It is set to prepare content and editable. - also in the NIB, a table view with two columns: one of checkboxes, bound to the Enabled property through the array controller, and one of text fields bound to the Name - an IBAction method, linked to a new button, which creates a new instance of the entity with the NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: method - This is a garbage-collected project. The new document is created with no instances of the entity. When clicking the new button, 9 times out of 10 everything seems fine. When it goes wrong, either the checkbox for the newly inserted entity doesn't draw at all, or it lacks the checkmark or the highlight or some other visual element. There is a console message like: 2008-09-29 11:32:56.955 IU Organ Utility v2[12568:10b] *** - [CIFilterClassDescription _feImage]: unrecognized selector sent to instance 0x10d32a0 2008-09-29 11:32:56.956 IU Organ Utility v2[12568:10b] Exception *** -[CIFilterClassDescription _feImage]: unrecognized selector sent to instance 0x10d32a0 Sometimes the class is _NSCFNumber or CIFilterShape instead of CIFilterClassDescription. Sometimes there's no message, but the app crashes with an EXC_BAD_ACCESS; and sometimes there's instead a message about free() which says something about a reference count underrun (sorry, I've been trying to repeat it while writing this and haven't managed to). Anyone have any ideas? Add a breakpoint on objc_exception_throw, and debug that app. Get a backtrace for when the exception is thrown. That may help you. See: http://www.corbinstreehouse.com/blog/index.php/2008/08/your-most-important-breakpoint-in-cocoa/ corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Tracking area pending install and disabled
Thanks for your reply. Unfortunately, I forgot to indicate that the code snippet I showed is in my updateTrackingAreas method, as it is in my previous project which is working. Regards, Dale Miller [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Questions on An NSOpenGL Application Design
When my application starts up, the user is presented with a settings window. It contains a view that will be attached to a web camera, and some widgets to control various filter settings. Once the settings are tweaked to the user's desire, the window will be closed, but the camera will still be processing images. In addition to standard CIFilters, I will also need to read the pixels back in from VRAM to perform an analysis on the CPU that I have yet to transform into a CIFilter. The way I plan on designing this application is to have an NSOpenGLView subclass to display my camera feed, and another class to control the camera and all of the image processing. Questions: 1. Should I stick with this design path? Some of the sample code I have seen puts what I have broken down into two classes all in the NSOpenGLView subclass, ie CIVideoDemoGL. 2. If I leave the code in two seperate files, do I need two OpenGLContexts, one for the view and one to link to a CIContext for the image filters, or can I just use the one from the NSOpenGLView? 3. When I bring the images back in from the GPU they will already be rendered with the CIFilters, so is it worth it to push them back out to OpenGL for drawing? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSWindowController retain count confusion
I have an NSWindowController subclass that is defined as File's Owner in a nib. The window outlet is connected to a window, and the delegate outlet of the window goes back to the File's Owner. I was trying to release the controller in the windowWillClose: delegate method, but it didn't cause the dealloc method to be called. I found that immediately after creating the controller with alloc and init, its retain count was 1, but as soon as I did [self window], the retain count went up to 2. So, who's retaining the controller, and is it safe to just release it twice? I searched the list, and found some old messages about NSWindowController retain counts being messed up by bindings, but I don't have any bindings (yet). -- James W. Walker, Innoventive Software LLC http://www.frameforge3d.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSWindowController retain count confusion
Hey James - The method -[NSObject retainCount] only exists to aid in debugging. You shouldn't be making any runtime decisions based on the return value of retainCount. You should only release something you previously retained/alloced/newed/copied or are for some other reason explicitly required to release. If you think you have a leak, you might consider running your app with Instruments's Object Alloc and Leaks tools. With those tools, you'll be able to get a backtrace for reach release, retain, and autorelease message sent to the instance of window you're curious about. If you were to add a double release, and it wasn't the case that your class was responsible for a double retain, then as soon as the unbalanced retain is found and fixed, your program will start crashing. Good luck - Jon Hess On Sep 29, 2008, at 7:30 PM, James Walker wrote: I have an NSWindowController subclass that is defined as File's Owner in a nib. The window outlet is connected to a window, and the delegate outlet of the window goes back to the File's Owner. I was trying to release the controller in the windowWillClose: delegate method, but it didn't cause the dealloc method to be called. I found that immediately after creating the controller with alloc and init, its retain count was 1, but as soon as I did [self window], the retain count went up to 2. So, who's retaining the controller, and is it safe to just release it twice? I searched the list, and found some old messages about NSWindowController retain counts being messed up by bindings, but I don't have any bindings (yet). -- James W. Walker, Innoventive Software LLC http://www.frameforge3d.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Drawing in a window with rounded corners
Hi, I have a custom view that takes up the whole frame of my textured window. Normally, the corners of a textured window are rounded. However, since my custom view is rectangular, it draws over the rounded corners. I am using Core Animation to draw in the view. I think what I need to do is clip my drawing so the corners are transparent, but I haven't been successful. What I've tried so far is drawing a rectangle with rounded corners that approximates the window's rounded corners using CGContextAddArcToPoint. Then I call CGContextClip. But it's not working, all I'm seeing is garbage at the window corners, not transparency. Any suggestions? Thanks, Dan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to count composed characters in NSString?
On Mon, Sep 29, 2008 at 12:52 AM, Michael Gardner [EMAIL PROTECTED] wrote: But composed character sequences aren't the problem; surrogate pairs are. Composed character sequences can be taken care of by using either -precomposedStringWithCanonicalMapping or -precomposedStringWithCompatibilityMapping. In my opinion, -length should take surrogate pairs into account, which is what the docs seem to imply. The NSString API is inherently either UCS-2 or UTF-16. As UCS-2 doesn't cover all of Unicode, it ends up being UTF-16. The API defines NSString as an ordered collection of 16-bit unichars. The length is necessarily the number of 16-bit unichars in the string, nothing else would really make sense. Short of creating a new API that works on pure Unicode code points, the only thing to do is to document the fact that -length gives you the number of UTF-16 code units, not the number of Unicode characters. (As an aside, changing the API to work with Unicode code points is something I don't think is really worthwhile. Aside from having to support the old API which would no doubt be a great deal of hassle, Unicode code points are pretty useless on their own anyway. You always end up having to convert and deal with precomposed characters an all the rest of the Unicode mess regardless. Adding surrogate pairs to all of that really doesn't increase the burden any further.) Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to count composed characters in NSString?
Hi Douglas and Peter, On Sep 29, 2008, at 6:39 PM, Douglas Davidson wrote: On Sep 28, 2008, at 11:17 AM, David Niemeijer wrote: I need to be able to display the number of characters to the user in a way that makes sense to them. If they see 3 I should report 3. I also need it to cut-off certain input to the number of real characters and should not generate results that only make sense for a language like English where each 16 bits equals a single character. What you are describing is the notion that Unicode sometimes refers to as a user-perceived character, which in general can be somewhat ambiguous, since different users may have different perceptions, and since there are writing systems in which character boundaries are not at all similar to those in English. To handle this sort of issue programmatically, Unicode defines what are known as grapheme clusters, but there is not a single notion of grapheme cluster; there are several such notions, depending on precisely what it is you want. These issues are covered in detail in Unicode Standard Annex #29, http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries , which gives a number of examples and some algorithms for determining grapheme cluster boundaries. Grapheme clusters are similar to but not quite identical to composed character sequences. For some purposes composed character sequences may be sufficient; NSString gives prominence to the notion of composed character sequence, because that is the most important concept for arbitrary text processing, but if you are really interested in user-perceived characters you may wish to use something else. Thanks for your clarification. It is indeed the grapheme clusters that I am after. I need to be able to do things such as capitalize the first letter of a string and in doing statistical text analysis determine the number of characters of a text string. This description from the URL you pointed at fits my use quite well: Grapheme cluster boundaries are important for collation, regular expressions, UI interactions (such as mouse selection, arrow key movement, backspacing), segmentation for vertical text, identification of boundaries for first-letter styling, and counting “character” positions within text. Using glyphs in this case is not appropriate as in text analysis the text itself is not displayed, nor is using [aString length] because it just reports the number of UTF-16 code units. I realize there is no perfect approach, but I am just trying to do something that brings me closest to what a user would expect. Peter confirmed earlier that CFStringGetRangeOfComposedCharactersAtIndex would be the way to go for me. But, if I read Douglas' comment then I am beginning to wonder whether this is the equivalent of UCFindTextBreak's kUCTextBreakCharMask and not of kUCTextBreakClusterMask. In the past I used to use UCFindTextBreak with kUCTextBreakClusterMask, but unlike NSString, UCFindTextBreak is not available on one of the platforms I need to support, so what would be the right way to get at the cluster breaks using the NSString API? (Please contact me off list if you need further clarification.) Cheers, david.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSManagedObject subclass accessor pattern mystery?
So I have a CoreData app (10.5.5, 64 bit only) that has a NSManagedObject that has an NSColor* that is part of its data model. Because this color is actually a computed value that we want to cache, it is declared as a property: @property (retain) NSColor* color; but since we may need to calculate it, we also map it to an instance variable _color: @synthesize color = _color; // we actually implement both setter and getter - should we stil declare this? - (NSColor*)color { [self willAccessValueForKey:@color]; if (!_color) { NSImage* img = [self thumbnail]; [self setColor:[img BW_representativeColor]]; } [self didAccessValueForKey:@color]; return _color; } - (void)setColor:(NSColor*)c { [self willAccessValueForKey:@color]; if (c != _color) { [self willChangeValueForKey:@color]; [_color release]; _color = [c copy]; [self didChangeValueForKey:@color]; } [self didAccessValueForKey:@color]; } So I understand that the willAccessValueForKey: gives CoreData the opportunity that when the color accessor is called, CoreData can sneakily go in and set _color for me, which is swell. The problem I have is that I want to cache the components of the color as well (as separate CGFloat properties), but I don't see where I can interpose myself to calculate and cache this when the color is set (either at run-time, or because it was calculated earlier and saved out to disk as part of the document). In other words, I read my document off of disk, and CoreData magically makes sure that my color property is set. But since it never seems to call my setColor: setter, I don't see it happen, which is when I would like to go ahead and cache my separate red, green, and blue properties. Since these are calculated from the color (which is saved), there's no reason to ever store them to disk. - (void)_cacheColor { NSColor* rgb = [_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; CGFloat red, green, blue, alpha; [rgb getRed:red green:green blue:blue alpha:alpha]; self.red = red; self.green = green; self.blue = blue; } - (void)setColor:(NSColor*)c { [self willAccessValueForKey:@color]; if (c != _color) { [self willChangeValueForKey:@color]; [_color release]; _color = [c copy]; [self didChangeValueForKey:@color]; [self _cacheColor]; } [self didAccessValueForKey:@color]; } I thought that perhaps if I just observed when the color property changed, I could fire then: - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)image change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@color]) { NSNumber* n = [change objectForKey:NSKeyValueChangeNewKey]; if ([n boolValue]) { [self _cacheColor]; } return ; } } but that code never seems to fire either. sigh. Digging into the documentation some more, it seemed that implementing this might do the trick: - (void)setPrimitiveValue:(id)value forKey:(NSString *)key { if ([key isEqualToString:@color]) { [self setColor:value]; return ; } [super setPrimitiveValue:value forKey:key]; } But again, it never fires. I'm assuming I'm missing something obvious... Thanks. -- Michael B. Johnson, PhD -- http://homepage.mac.com/drwave (personal) -- http://xenia.media.mit.edu/~wave (alum) -- MPG Lead -- Pixar Animation Studios ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSManagedObject subclass accessor pattern mystery?
On Sep 29, 2008, at 11:44 PM, Michael B Johnson wrote: So I have a CoreData app (10.5.5, 64 bit only) that has a NSManagedObject that has an NSColor* that is part of its data model. Because this color is actually a computed value that we want to cache, it is declared as a property: Have you read the Non-Standard Persistent Attributes of the Core Data guide? It gives you several ways of doing this and even uses NSColor as an example: http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html The easiest way, if you can require 10.5, is to use a transformable attribute. Core Data will automatically transform your NSColor to and from NSData using an NSValueTransformer. In other words, I read my document off of disk, and CoreData magically makes sure that my color property is set. But since it never seems to call my setColor: setter, I don't see it happen, which is when I would like to go ahead and cache my separate red, green, and blue properties. Since these are calculated from the color (which is saved), there's no reason to ever store them to disk. If you want to cache the RGB values, you'll probably want to follow the instructions in Custom Code. Perhaps a pre-calculated getter and an immediate-update setter? In awakeFromFetch and setColor: you could update the RGB values as well as the primitive color. -Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to count composed characters in NSString?
On Sep 29, 2008, at 9:27 PM, David Niemeijer wrote: Hi Douglas and Peter, On Sep 29, 2008, at 6:39 PM, Douglas Davidson wrote: On Sep 28, 2008, at 11:17 AM, David Niemeijer wrote: I need to be able to display the number of characters to the user in a way that makes sense to them. If they see 3 I should report 3. I also need it to cut-off certain input to the number of real characters and should not generate results that only make sense for a language like English where each 16 bits equals a single character. What you are describing is the notion that Unicode sometimes refers to as a user-perceived character, which in general can be somewhat ambiguous, since different users may have different perceptions, and since there are writing systems in which character boundaries are not at all similar to those in English. To handle this sort of issue programmatically, Unicode defines what are known as grapheme clusters, but there is not a single notion of grapheme cluster; there are several such notions, depending on precisely what it is you want. These issues are covered in detail in Unicode Standard Annex #29, http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries , which gives a number of examples and some algorithms for determining grapheme cluster boundaries. Grapheme clusters are similar to but not quite identical to composed character sequences. For some purposes composed character sequences may be sufficient; NSString gives prominence to the notion of composed character sequence, because that is the most important concept for arbitrary text processing, but if you are really interested in user- perceived characters you may wish to use something else. Thanks for your clarification. It is indeed the grapheme clusters that I am after. I need to be able to do things such as capitalize the first letter of a string and in doing statistical text analysis determine the number of characters of a text string. This description from the URL you pointed at fits my use quite well: Grapheme cluster boundaries are important for collation, regular expressions, UI interactions (such as mouse selection, arrow key movement, backspacing), segmentation for vertical text, identification of boundaries for first-letter styling, and counting “character” positions within text. Using glyphs in this case is not appropriate as in text analysis the text itself is not displayed, nor is using [aString length] because it just reports the number of UTF-16 code units. I realize there is no perfect approach, but I am just trying to do something that brings me closest to what a user would expect. Peter confirmed earlier that CFStringGetRangeOfComposedCharactersAtIndex would be the way to go for me. But, if I read Douglas' comment then I am beginning to wonder whether this is the equivalent of UCFindTextBreak's kUCTextBreakCharMask and not of kUCTextBreakClusterMask. In the past I used to use UCFindTextBreak with kUCTextBreakClusterMask, but unlike NSString, UCFindTextBreak is not available on one of the platforms I need to support, so what would be the right way to get at the cluster breaks using the NSString API? (Please contact me off list if you need further clarification.) Cheers, david. David, CFStringGetRangeOfComposedCharactersAtIndex and -[NSString rangeOfComposedCharacterSequenceAtIndex:] are the modern replacements for UCFindTextBreak with kUCTextBreakClusterMask and indeed they now are closer to the original intent of kUCTextBreakClusterMask that the current implementation of kUCTextBreakClusterMask is (since UCFindTextBreak was converted to follow Unicode/ICU default text segmentation rules). The modern functions treat all of the following as a cluster: - A surrogate pair (of course, since it is a single character); - A base character followed by a sequence of combining marks (whether or not this is something that would be composed under NFC); - A Hangul syllable expressed as a sequence of conjoining jamo; - An Indic consonant cluster such as consonant + virama + consonant + vowel matra. It is this latter cluster that is no longer treated as a single entity by UCFindTextBreak with kUCTextBreakClusterMask. -Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]