Running run loops in 10.6 (was: Need -[NSTask waitUntilExitOrTimeout:])
On 2009 Sep 16, at 14:07, Chris Kane wrote: On Sep 14, 2009, at 6:29 PM, I wrote: [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:limitTime] ; // The above will block and be run to here either due to // the posting of an NSTaskDidTerminateNotification, ... That is not a valid assumption (described in the comments and apparent from the rest of the code). Yup. It works in 10.5 but not 10.6. Something is tickling this run loop in 10.5, within a few milliseconds of the NSTaskDidTerminateNotification, so I thought it was the notification itself. Re-reading about Run Loops in Threading Programming Guide [1], I learn that notifications are in fact *not* input sources. The difference in 10.6 is probably explained in the 10.6 Cocoa Foundation Release Notes [2], which I would paraphrase as run loops which were tickled into running by mysterious input sources in 10.5 may no longer get those tickles in 10.6. Someone please correct me if I misunderstood. So, I'd like to implement Chris Kane's preferred solution Go back to the main thread. Setup a oneshot NSTimer for the timeout period. Setup a notification handler to listen for the NSTaskDidTerminateNotification. If the timer fires first, kill the task, unregister the notification handler, etc. If the notification happens first, invalidate the timer, unregister the notification handler, etc. Don't run the run loop yourself. Let your code be event-driven. That would certainly work, but I sometimes need to run this show in a background worker tool, or in secondary thread -- not just in the main thread of an app. How can I detect notifications and use them for controlling program flow in a non-event-driven environment? To illustrate the problem, I've appended a demo program [3]. Like my original code, the demo works in 10.5 -- the timeout and NSTaskDidTerminateNotification are received *and* the run loop runs... 21:35:56.969 TestTool[366:10b] ver 1.2 21:35:56.982 TestTool[366:10b] Will run run loop 21:35:56.985 TestTool[366:10b]top of loop 21:35:57.122 TestTool[366:10b] Succeeded : Task with timeout: 1.00 cmd: /bin/sleep 0.10 21:35:57.124 TestTool[366:10b]moreInputSources = 1 21:35:57.164 TestTool[366:10b]nTasks = 1 21:35:57.171 TestTool[366:10b]top of loop 21:35:57.481 TestTool[366:10b] Timed out : Task with timeout: 0.50 cmd: /bin/sleep 0.80 21:35:57.795 TestTool[366:10b]moreInputSources = 1 21:35:57.797 TestTool[366:10b]nTasks = 0 21:35:57.798 TestTool[366:10b] All tasks are done. Exitting. Running same executable in 10.6, the run loop never runs, and thus the program never exits... 22:05:14.137 TestTool[141:903] ver 1.2 22:05:14.152 TestTool[141:903] Will run run loop 22:05:14.154 TestTool[141:903]top of loop 22:05:14.254 TestTool[141:903] Succeeded : Task with timeout: 1.00 cmd: /bin/sleep 0.10 22:05:14.643 TestTool[141:903] Timed out : Task with timeout: 0.50 cmd: /bin/sleep 0.80 P.S. Interesting how run loops work. As you can see from the code, after logging 22:05:14 top of loop, the next statement invokes - runMode:beforeDate: which apparently blocks forever because the NSLog in the following line never logs. But, while it's blocked there, it still receives and processes the NSTaskDidTerminateNotification and timer firing. Thanks very much, Jerry Krinock 1. http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#/ /apple_ref/doc/uid/1057i-CH16-SW19 2. http://developer.apple.com/mac/library/releasenotes/Cocoa/Foundation.html See the end of the second paragraph of the section named Concurrency, GCD, and Run Loop Cautions (New since November seed) 3. Demo Program /* This program creates two TaskWrapper objects. Each TaskWrapper runs an NSTask launching /bin/sleep. The first one succeeds because its sleep argument of 0.1 seconds is less than its timeout of 1.0 seconds. The second one times out because its sleep argument of 0.8 seconds is greater than its timeout time of 0.5 seconds. */ #import Cocoa/Cocoa.h static NSMutableArray* activeTaskWrappers ; @interface TaskWrapper : NSObject { NSTask* m_task ; NSTimer* m_timeoutTimer ; NSString* m_signature ; NSString* m_status ; } @property (retain) NSTask* task ; @property (retain) NSTimer* timeoutTimer ; @property (copy) NSString* signature ; @property (copy) NSString* status ; @end @implementation TaskWrapper @synthesize task = m_task ; @synthesize timeoutTimer = m_timeoutTimer ; @synthesize signature = m_signature ; @synthesize status = m_status ; - (void)dealloc { [m_task release] ; [m_timeoutTimer release] ; [m_signature release] ; [super dealloc] ; } - (void)doShellTaskCommand:(NSString*)command arguments:(NSArray*)arguments timeout:(NSTimeInterval)timeout {
NSView / NSControl / NSCell drawing question
Hey All, quick question. I think this is straight forward, but just wanted some verification before I move forward too far. To keep a long story somewhat short - I have a custom view, which I am placing a custom control into, and am curious if it's proper to specifically be calling the drawRect method of a control from my subclassed NSView. Here are the classes: http://pastebin.com/m4fb2d114 (a base view) http://pastebin.com/m2835d3f6 (subclassed view) http://pastebin.com/m6ab006a6 (the control) http://pastebin.com/m4ded8d96 (the cell) Like I said, I'm not very far, but wanted to verify the explicit call to the control draw method. Is this the correct way? Thanks much! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Running Safari from application
Hi, I try to open local html file in Safari from my application. I use this code: - (void)viewDidLoad { [super viewDidLoad]; username = [[NSUserDefaults standardUserDefaults] stringForKey: @username]; password = [[NSUserDefaults standardUserDefaults] stringForKey: @password]; if ([username length] == 0 || [password length] == 0) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: alertTitle message: alertMessage delegate: self cancelButtonTitle: alertCancelButtonTitle otherButtonTitles: nil]; [alert show]; [alert release]; } else { if ([self saveHtmlFile]) [self showPageInSafari]; } } - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { exit(0); } } - (BOOL) saveHtmlFile { NSString *fileContent = [NSString stringWithFormat: @htmlheadscript type=\text/javascript\function send_request() { var form = document.getElementById(\login\); form.submit(); }/script/headbody onload='send_request();'form id='login' action='https://www.example.com/index.php' method='post'input id='username' name='username' type='hidden' value='%@' /input type='hidden' id='password' name='password' value='%@' //form/body/html, username, password]; NSError *error; return [fileContent writeToFile: [self getPathToHtmlFile] atomically: YES encoding: NSUnicodeStringEncoding error: error]; } - (void) showPageInSafari { [[UIApplication sharedApplication] openURL: [NSURL fileURLWithPath: [self getPathToHtmlFile]]]; } - (NSString *) getPathToHtmlFile { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSDocumentDirectory, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [NSString stringWithFormat: @%@/login.html, documentsDirectory]; } The problem is that the safari is not launched. If I put in showPageInSafari function openURL: [NSURL URLWithString: @http://www.example.com/index.php;] then it works. Do you know what is wrong? Thanks Bartosz Bialecki Znajdź mieszkanie dla siebie! Porównaj i kup. http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fogloszenia_nier.htmlsid=862 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSView / NSControl / NSCell drawing question
nvmind. I got it all figured out. Just by adding the control the a view, it automatically calls the drawing methods. Thanks. On Thu, Sep 17, 2009 at 11:04 PM, aaron smith beingthexemplaryli...@gmail.com wrote: Hey All, quick question. I think this is straight forward, but just wanted some verification before I move forward too far. To keep a long story somewhat short - I have a custom view, which I am placing a custom control into, and am curious if it's proper to specifically be calling the drawRect method of a control from my subclassed NSView. Here are the classes: http://pastebin.com/m4fb2d114 (a base view) http://pastebin.com/m2835d3f6 (subclassed view) http://pastebin.com/m6ab006a6 (the control) http://pastebin.com/m4ded8d96 (the cell) Like I said, I'm not very far, but wanted to verify the explicit call to the control draw method. Is this the correct way? Thanks much! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Handling mouse events in NSCell's?
What's the proper way of handling simple mouse events in NSCell's? Like mouseUp, mouseDown, etc. I see that an NSControl implements NSResponder, but wasn't sure if that's the right way to do it. Because of the fact that tables usually use cell's rather than a control. I've also been looking at the method trackMouse:inRect:ofView:untilMouseUp: but this method doesn't ever get fired when the mouse is up. Any ideas? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Handling mouse events in NSCell's?
Hi Aaron, You should take a look at the NSCell docshttp://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/trackMouse:inRect:ofView:untilMouseUp: . -Ken trackMouse:inRect:ofView:untilMouseUp: Discussion This method is *generally not overridden* because the default implementation invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the * untilMouseUp* flag. If *untilMouseUp* is set to YES, this method returns YES if the mouse button goes up while the cursor is anywhere; NO, otherwise. If * untilMouseUp* is set to NO, this method returns YES if the mouse button goes up while the cursor is within *cellFrame*; NO, otherwise. This method first invokes *startTrackingAt:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/startTrackingAt:inView:. If that method returns YES, then as mouse-dragged events are intercepted, * continueTracking:at:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/continueTracking:at:inView: is invoked until either the method returns NO or the mouse is released. Finally, *stopTracking:at:inView:mouseIsUp:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/stopTracking:at:inView:mouseIsUp: is invoked if the mouse is released. If *untilMouseUp* is YES, it’s invoked when the mouse button goes up while the cursor is anywhere. If *untilMouseUp * is NO, it’s invoked when the mouse button goes up while the cursor is within *cellFrame*. You usually override one or more of these methods to respond to specific mouse events. On Fri, Sep 18, 2009 at 1:33 AM, aaron smith beingthexemplaryli...@gmail.com wrote: What's the proper way of handling simple mouse events in NSCell's? Like mouseUp, mouseDown, etc. I see that an NSControl implements NSResponder, but wasn't sure if that's the right way to do it. Because of the fact that tables usually use cell's rather than a control. I've also been looking at the method trackMouse:inRect:ofView:untilMouseUp: but this method doesn't ever get fired when the mouse is up. Any ideas? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSRunLoop issue
On Sep 17, 2009, at 7:01 PM, Jean-Daniel Dupas wrote: Le 17 sept. 2009 à 18:28, Jerry Krinock a écrit : On 2009 Sep 17, at 07:48, Jean-Daniel Dupas wrote: Add a dummy source (mach port or timer with an insanely high fire date) before running your loop. So you re sure there is at least one source. Please show a few lines of code adding a dummy mach port. One time I tried to do that and kept going around in circles in the documentation. [[NSRunLoop currentRunLoop] addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; Thank you Jean-Daniel for the tip. I'm using a dummy timer currently - but the mach port approach looks better. Thanks! Jerry Krinock -- Jean-Daniel Regards Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Building a 64-bit Preferences Pane
I just realized that the dev forums for Mac is only available for Select or Premier member of ADC, not the online member. Do you mind to share the solution ? Jesse Armand (http://jessearmand.com) 2009/4/30 慧 松本 sato...@mac.com: Thanks!! My problem was resolved at https://devforums.apple.com/community/mac Satoshi On 2009/04/30, at 12:59, Clark Cox wrote: 2009/4/29 慧 松本 sato...@mac.com: On 2009/04/30, at 12:05, Andrew Farmer wrote: On 29 Apr 09, at 19:48, 慧 松本 wrote: Does anybody know how to make 64-bit preference panes? You can't, yet. The System Preferences application - which loads preference panes as plugins - is still 32-bit only, so it can't load 64-bit prefpane plugins. Sorry, I forgot to mention my OS environment. I am developing the preference pane on Mac OS X 10.6 Snow Leopard build 10A335. Does my question violate NDA? Take it to https://devforums.apple.com/community/mac -- Clark S. Cox III clarkc...@gmail.com - Satoshi Matsumoto sato...@mac.com 816-5 Odake, Odawara, Kanagawa, Japan 256-0802 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/mnemonic.fx%40gmail.com This email sent to mnemonic...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
init for immutable classes
Hello, I am writing a framework which runs on both Snow Leopard and the iPhone (i.e. it is entirely foundation stuff). I always write my init and dealloc methods using the setter functions, but I am wondering what the proper convention is for immutable classes? Should I write a private setter method, or is it ok to just set the variable in init and release it in -dealloc. Thus: Option 1) -(id)initWithValue:(id)aValue { if(self=[super init]){ [self setValue:aValue]; } return self; } -(void)dealloc { [self setValue:nil]; [super dealloc]; } Option 2) -(id)initWithValue:(id)aValue { if(self=[super init]){ _value = [aValue copy]; } return self; } -(void)dealloc { [[self value] release]; [super dealloc]; } Is ether one better for a particular reason, or are they both ok, and it is just a matter of style? I am thinking that the second is probably better, because even a 'private' method could get called from outside of the class, and I couldn't guarantee it's immutability anymore. That is so different from what I normally do (I was taught to always use setter methods) that I wanted to check with the list first... Thanks, Jon ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Populating TableView Via Button.
Hi! Does anyone know how you'd populate a tableview when clicking a button? I tried this: AppController.h: - (void)populateTableView:(id)sender; AppController.m: -(void)populateTableView:(id)sender { [super init]; sourceArray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @test 1, @title, [NSURL fileURLWithPath:@/Library/1.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 2, @title, [NSURL fileURLWithPath:@/Library/2.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 3, @title, [NSURL fileURLWithPath:@/Library/3.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 4, @title, [NSURL fileURLWithPath:@/Library/4.html], @url, nil], nil]; return self; } This doesn't work. If I replace the void function in the class .m file with (id) init, everything works fine. But then it populates the tableview on launch and I'd like to populate the tableView only when I click a button. --Philip ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Populating TableView Via Button.
On Sep 18, 2009, at 9:34 AM, Philip Juel Borges wrote: Does anyone know how you'd populate a tableview when clicking a button? Nope. That kind of high-tech stuff is beyond any Cocoa developer. ;-) I tried this: -(void)populateTableView:(id)sender { [super init]; ... return self; } This doesn't work. If I replace the void function in the class .m file with (id) init, everything works fine. But then it populates the tableview on launch and I'd like to populate the tableView only when I click a button. In all seriousness, there are a number of things that seem to be wrong with your understanding of Objective-C and the Cocoa frameworks. So first of all, this code example goes beyond trouble populating the table view. It's as much to do with initializing (what I assume must be) an instance variable called sourceArray. Since you said everything works fine (ie, you see things in your table) when you take another approach, I'll assume your table datasource (or bindings) setup is configured correctly. Second, this very strange call you make to [super init] is inexplicable. There's just no good reason to call your class's superclass's init or even the class's own init method from some random place within your class. Even if you give a good technical reason, I'd argue you don't. :-) Read the Allocating and Initializing Objects section of the Objective C 2.0 Programming Language guide to get a better idea of the hows and whys: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#//apple_ref/doc/uid/TP30001163-CH22-SW1 Third, you're returning self within a method that claims to return nothing at all (void). I assume this and the call to [super init] are a result of your trying to get things working (and moving them to a method that you can call yourself, directly). Unfortunately both these issues will only confuse things further. Move initialization stuff back to your init method and diagnose the real problem. Fourth - the real problem: You never ask the table to -reloadData (if you're using the NSTableDataSource protocol) or you never tell the NSArrayController where to get its information. So it comes down to that ... are you using the data source protocol or bindings? If you're using the data source protocol, all you need to do is tell the table view to -reloadData when you've changed its data. If you're using Bindings, it's a bit more complicated: you need to change your sourceArray in a KVO-compliant way so the array controller to which your table is bound hears about the change. Search the archives for phrases like, changing the array behind the controller's back and read: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueObserving/ (Better yet, create KVC/KVO-compliant accessors for your sourceArray and use those to set a new array. Using Objective-C 2.0 properties makes this *very* easy.) -- 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 arch...@mail-archive.com
Re: +keyPathsForValuesAffectingKey not working for a category-implemented property on a CoreData class
Thanks for the help; all better now. Comments inline. On Thu, Sep 17, 2009 at 12:42 PM, Quincey Morris quinceymor...@earthlink.net wrote: On Sep 17, 2009, at 05:44, Doug Knowles wrote: In a CoreData entity called Topic, I have a to-many relationship (to other Topics) called children to implement a hierarchy. In a category on Topic, I have implemented a property called orderedChildren which returns a sorted array of the children. In order to ensure that orderedChildren is recognized as a property of the Topic entity, I have defined orderedChildren as an optional, transient attribute of Topic of unknown type (since NSArray or id isn't supported). CoreData generates a property declaration for orderedChildren with type UNKNOWN_TYPE, and I have #defined UNKNOWN_TYPE as id in my precompiled header. It's not at all obvious that following this strategy (creating the transient attribute) does you any good whatsoever. OTOH, it's not at all obvious that it does any harm WRT to the problem you're having. I did this in a misguided attempt to eliminate a unimplemented method warning, which was properly fixed by including the category's header. What doesn't work is defining a class method +keyPathsForValuesAffectingOrderedChildren, which I'd like to use to cause changes in the children relationship to trigger change notifications for orderedChildren. keyPathsForValuesAffectingOrderedChildren is never called. (Overriding keyPathsForValuesAffectingValueForKey: from a category is verboten.) Prima facie, the reason 'keyPathsForValuesAffectingOrderedChildren' doesn't get called would be that nothing is observing the property. Maybe that aspect deserves attention ahead of the Core Data side of it. Have you tried writing some debugging code that (a) installs a KVO observer on the orderedChildren property of a Topic object, and (b) changes the children property, to see whether (c) observeValueForKeyPath:... is invoked for key orderedChildren? Sigh, And thereby hangs the problem: the observer I thought I added was missing. Adding the observer back yields the expected results, and keyPathsForValuesAffectingOrderedChildren is being called. Narrowing the problem definition might be the most useful thing you could do. Also, sorry if it's a stupid question, but you have checked the console log for exception messages, haven't you? It often happens, with KVO-related problems, that an application can appear to run *almost* correctly after an exception is logged and ignored. There are no stupid questions, especially from people like yourself willing to lend some assistance here. In this case, I have a permanent (if sometimes disabled) on objc_exception_throw that I use to help make sure I don't miss exceptions. Many thanks again. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Populating TableView Via Button.
Would an alternative implementation be to have the button click swap in a view with a NSTableView bound to its data source? -S On Fri, Sep 18, 2009 at 9:34 AM, Philip Juel Borges philipjbor...@gmail.com wrote: Hi! Does anyone know how you'd populate a tableview when clicking a button? I tried this: AppController.h: - (void)populateTableView:(id)sender; AppController.m: -(void)populateTableView:(id)sender { [super init]; sourceArray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @test 1, @title, [NSURL fileURLWithPath:@/Library/1.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 2, @title, [NSURL fileURLWithPath:@/Library/2.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 3, @title, [NSURL fileURLWithPath:@/Library/3.html], @url, nil], [NSDictionary dictionaryWithObjectsAndKeys: @test 4, @title, [NSURL fileURLWithPath:@/Library/4.html], @url, nil], nil]; return self; } This doesn't work. If I replace the void function in the class .m file with (id) init, everything works fine. But then it populates the tableview on launch and I'd like to populate the tableView only when I click a button. --Philip ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/skline1967%40gmail.com This email sent to skline1...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
If someone could inspect this code and explain to me what am I doing wrong ?
Hello to the list ! As the title say, I could use home help. I'm still on the learning path. This code is attempt of implementing a Leopard style source list using a NSOutlineView. Code provided below works but as seen from the console output of NSLog's it displays come cell's number of times which probably means that my implementation of some methods is fault in some part. Also execution is noticeable slow. I would be grateful if someone could inspect this code and explain to me where are my mistakes and point out possible solutions which would improve this code. It would be very useful for my better understanding and future learning. Also to mention that I have read Apple's documentation regarding the subject and have downloaded and examine a lot of examples of source list implementations but those examples were just too complicated to understand how to implement data source methods, and documentation on the other hand is too general. If someone wants to test this code in the Xcode just a remainder to connect IBOutlet, data source and delegate connections in Interface Builder. And at the end there is a delegate method implementation but I comment it out because it is also fault. It makes things even worse. Please review it too and explain to me what did I missed out. Thanks for help ! #import Cocoa/Cocoa.h @interface LSOutlineDataSource : NSObject { IBOutlet NSOutlineView *lsOutlineView; NSMutableArray *sourceListLevelZero; } @property (assign) NSMutableArray *sourceListLevelZero; @end --- #import LSOutlineDataSource.h @implementation LSOutlineDataSource @synthesize sourceListLevelZero; - (id)init { if (self = [super init]) { sourceListLevelZero = [[NSMutableArray alloc] init]; NSMutableDictionary *showOne = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@NEWS AT 6, @nameOfShow, [[NSMutableArray alloc] initWithObjects:@MONDAY, @TUESDAY, @WEDNESDAY, @THURSDAY, @FRIDAY, @SATURDAY, @SUNDAY, nil], @listOfShowsRundownLists, nil]; [sourceListLevelZero addObject:showOne]; [showOne release]; NSMutableDictionary *showTwo = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@NEWS AT 10, @nameOfShow, [[NSMutableArray alloc] initWithObjects:@MONDAY, @TUESDAY, @WEDNESDAY, @THURSDAY, @FRIDAY, @SATURDAY, @SUNDAY, nil], @listOfShowsRundownLists, nil]; [sourceListLevelZero addObject:showTwo]; [showTwo release]; } return self; } - (void)awakeFromNib { [lsOutlineView expandItem:nil expandChildren:NO]; } - (void)dealloc { [sourceListLevelZero release]; [super dealloc]; } #pragma mark NSOutlineViewDataSource protocol methods - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { if (item == nil) { item = sourceListLevelZero; NSLog(@1 - item number of children is %i, [item count]); return [item count]; } if ([item isKindOfClass:[NSDictionary class]]) { NSLog(@1.1 - item number of children is %i, [[item objectForKey:@listOfShowsRundownLists] count]); return [[item objectForKey:@listOfShowsRundownLists] count]; } NSLog(@1.2 - item number of children is 0); return 0; } - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { if (item == nil) { item = sourceListLevelZero; NSLog(@2 - item at index %i is %@, index, [item objectAtIndex:index]); return [item objectAtIndex:index]; } if ([item isKindOfClass:[NSDictionary class]]) { NSLog(@2.1 - item for key \listOfShowsRundownLists\ at index %i is %@, index, [[item objectForKey:@listOfShowsRundownLists] objectAtIndex:index]); return [[item objectForKey:@listOfShowsRundownLists] objectAtIndex:index]; } NSLog(@2.2 - item is not valid); return nil; } - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable: (id)item { if ([item isKindOfClass:[NSArray class]] || [item isKindOfClass: [NSDictionary class]]) { if ([item count] 0) { NSLog(@3 - item is expandable); return YES; } } NSLog(@3.1 - item is not expandable); return NO; } - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { if ([item
Re: init for immutable classes
On Sep 18, 2009, at 4:10 AM, Jon Hull jh...@gbis.com wrote: I always write my init and dealloc methods using the setter functions, but I am wondering what the proper convention is for immutable classes? Should I write a private setter method, or is it ok to just set the variable in init and release it in -dealloc. Thus: Never use accessors in -init or -dealloc. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running Safari from application
On 18.09.2009, at 10:26, Bartosz Białecki wrote: The problem is that the safari is not launched. If I put in showPageInSafari function openURL: [NSURL URLWithString: @http://www.example.com/index.php;] then it works. Do you know what is wrong? Could it be that the path is not accessible for Safari? Remember, iPhone apps are sandboxed to prevent them from messing with each other's files. Cheers, -- Uli___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: init for immutable classes
On 18.09.2009, at 13:10, Jon Hull wrote: I am writing a framework which runs on both Snow Leopard and the iPhone (i.e. it is entirely foundation stuff). I always write my init and dealloc methods using the setter functions, but I am wondering what the proper convention is for immutable classes? Should I write a private setter method, or is it ok to just set the variable in init and release it in -dealloc. Thus: (...) Is ether one better for a particular reason, or are they both ok, and it is just a matter of style? I am thinking that the second is probably better, because even a 'private' method could get called from outside of the class, and I couldn't guarantee it's immutability anymore. That is so different from what I normally do (I was taught to always use setter methods) that I wanted to check with the list first... See here for a rationale on why it could be a bad idea to use accessors in init methods (and maybe even destructors): http://zathras.de/blog-defensive-coding-in-objective-c.htm And since immutable objects are not intended to be mutated at all, there should be only two places where ivars are changed: init and dealloc, so I don't think there's any need for mutators (accessors, for reading, are likely needed anyway). Cheers, -- Uli Kusterer The witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
CalCalendarStore Breaking a Recurring Event
Hello everyone, I've encountered a bug/limitation with the CalCalendarStore. The situation in a nutshell: 1) Add an event with a recurrenceRule repeating everyday for 2 days. 2) Delete the first event (could be either) 3) Now try to undo the users action by inserting the event back in. CalCalendarStore will not insert the record back in. When a user breaks a recurring event in iCal by deleting an event, iCal sends a CalUpdatedRecordsKey notification. (No CalDeletedRecordsKey is posted.) When the user undos the action, iCal then posts CalUpdatedRecordsKey again. (No CalInsertedRecordsKey is posted.) When I examine the events, the properties all remain unchanged... My issue is in my App I break the recurrenceRule by deleting and event using CalCalendarStore removeEvent: span: error:. This works exactly the way I would like, however when the user undos their action CalCalendarStore saveEvent: span: error: is used but the event is not re-inserted. I do not know what property to modify so it will take it back. If I knew what property to update instead of deleting the event i'd do that, but I can't find it! Any ideas how I should handle the situation? Snow Leopard 10.6.1 Brad Goss brad.g...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Reliable way to find out if CoreData finished loading
Hi, I'm loading Core Data object via Managed Object Context in IB. It looks like it hasn't finished loading when applicationDidFinishLoading is fired. What is the appropriate way to do smth once Managed Object Context is loaded? Mantas Masalskis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
2 simple questions
1. How do I programmatically open a folder window? And open a webpage using the default browser? 2. How do I change the icon for a folder I have created programmatically? How do I get it to list it under Places (on the left of the Finder window) programmatically? Thanks K ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Building a 64-bit Preferences Pane
Okay thanks, I also found the solution from a blog somewhere while searching. It's weird how Apple lay out all of the important things about 64-bit in the docs, but left out this one somewhere that I couldn't find easily. I also ran the script to check for 64-bit compatibility, added the proper #ifdef for it (it's only about data types). 2009/9/18 MATSUMOTO Satoshi sato...@mac.com: Hi, Building 64-bit Preferences Pane... In response to satoshi on Apr 30, 2009 2:21 PM I have been trying to make a simple 64-bit Preference Pane on Snow Leopard buid 10A335. But all trials ended in failure. For example: 1) Make a new preference pane project SamplePrefPane with Xcode. 2) Set the build option ARCHS to x86_64 3) Build it and double click SamplePrefPane.prefPane ANSWER 2.5) turn on Garbage Collection. (Search for garbage collection in build settings inspector) On Snow Leopard, System Preferences has garbage collection enabled when launched as a 64 bit application (default on 64 bit capable machines). If you intend on supporting both 32 bit and 64 bit machines, you'll need to build your preference pane as a dual mode module; gc supported instead of gc only. Then System Preferences app says: Preferences Error You can't open SimplePrefPane preferences because it doesn't work on an Intel-based Mac. That is a horribly failure message. Please file a bug via http://bugreporter.apple.com/. Satoshi Jesse Armand (http://jessearmand.com) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: 2 simple questions
Hi Kennedy, let me introduce you to a brand-new tool called Google. You can find it at http://www.google.com and you type in your questions, and generally the first to third items in the replies it gives you tell you exactly how to solve your problem. For those questions where I easily found the answer by googling, I'll just paste the Google URL with the question I typed in here. On 18.09.2009, at 17:44, Kennedy Kok wrote: 1. How do I programmatically open a folder window? http://www.google.com/search?client=safarirls=enq=cocoa+open+finder+windowie=UTF-8oe=UTF-8 And open a webpage using the default browser? http://www.google.com/search?client=safarirls=enq=cocoa+open+web+pageie=UTF-8oe=UTF-8 2. How do I change the icon for a folder I have created programmatically? http://www.google.com/search?client=safarirls=enq=cocoa+custom+icon+for+folderie=UTF-8oe=UTF-8 How do I get it to list it under Places (on the left of the Finder window) programmatically? That last one doesn't really have an official solution. I suggest you look into using AppleScript to do that, and if that fails, you could use a program like FSEventer to find out which file Finder writes this info to (it's probably a plist and it probably writes a file path or Alias data (NSURL bookmark data) to that plist). Cheers, -- Uli Kusterer The witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reliable way to find out if CoreData finished loading
Hi Mantas, What are you trying to do? - S On Thu, Sep 17, 2009 at 6:46 PM, Mantas Masalskis man...@idev.lt wrote: Hi, I'm loading Core Data object via Managed Object Context in IB. It looks like it hasn't finished loading when applicationDidFinishLoading is fired. What is the appropriate way to do smth once Managed Object Context is loaded? Mantas Masalskis ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/skline1967%40gmail.com This email sent to skline1...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Reliable way to find out if CoreData finished loading
On Sep 17, 2009, at 6:46 PM, Mantas Masalskis wrote: I'm loading Core Data object via Managed Object Context in IB. It looks like it hasn't finished loading when applicationDidFinishLoading is fired. Perhaps thinking about this a different way would clarify things. You don't load a context. You create a context and use it to fetch objects from the store (or merely to create objects if you're using an in-memory store). So, if you have some controllers that aren't ready yet, you can simply instruct them to -fetch: ... this will force them to fetch immediately, rather than waiting for a future cycle of the run loop. What is the appropriate way to do smth once Managed Object Context is loaded? What's a smth? -- 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 arch...@mail-archive.com
Re: Building a 64-bit Preferences Pane
On Sep 18, 2009, at 9:01 AM, Jesse Armand mnemonic...@gmail.com wrote: It's weird how Apple lay out all of the important things about 64-bit in the docs, but left out this one somewhere that I couldn't find easily. Garbage collection and 64-bit are orthogonal issues. A process can be one, both, or neither. If you're building a bundle to be loaded by another app, use otool on the app to figure out what kind of bundle you need to be. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Handling mouse events in NSCell's?
I agree with Ken and strongly encourage you to use the three tracking methods already defined in the NSCell documentation raleigh. On Sep 18, 2009, at 2:12 AM, Ken Ferry wrote: Hi Aaron, You should take a look at the NSCell docshttp://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/trackMouse:inRect:ofView:untilMouseUp: . -Ken trackMouse:inRect:ofView:untilMouseUp: Discussion This method is *generally not overridden* because the default implementation invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the * untilMouseUp* flag. If *untilMouseUp* is set to YES, this method returns YES if the mouse button goes up while the cursor is anywhere; NO, otherwise. If * untilMouseUp* is set to NO, this method returns YES if the mouse button goes up while the cursor is within *cellFrame*; NO, otherwise. This method first invokes *startTrackingAt:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/startTrackingAt:inView: . If that method returns YES, then as mouse-dragged events are intercepted, * continueTracking:at:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/continueTracking:at:inView: is invoked until either the method returns NO or the mouse is released. Finally, *stopTracking:at:inView:mouseIsUp:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/stopTracking:at:inView:mouseIsUp: is invoked if the mouse is released. If *untilMouseUp* is YES, it’s invoked when the mouse button goes up while the cursor is anywhere. If *untilMouseUp * is NO, it’s invoked when the mouse button goes up while the cursor is within *cellFrame*. You usually override one or more of these methods to respond to specific mouse events. On Fri, Sep 18, 2009 at 1:33 AM, aaron smith beingthexemplaryli...@gmail.com wrote: What's the proper way of handling simple mouse events in NSCell's? Like mouseUp, mouseDown, etc. I see that an NSControl implements NSResponder, but wasn't sure if that's the right way to do it. Because of the fact that tables usually use cell's rather than a control. I've also been looking at the method trackMouse:inRect:ofView:untilMouseUp: but this method doesn't ever get fired when the mouse is up. Any ideas? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com This email sent to le...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Printing with Snow Leopard
Hi Gerriet, You are printing the same instance of a view that is in your UI. So basically, your are trying to get the same view to print on two threads. Unless your view can handle concurrent drawing, this could be bad. NSTextView doesn't support concurrent drawing. I think you were getting lucky on Leopard. Possible solutions: 1. Don't print concurrently. 2. Create another view and set it up with the content from your UI. Use this view for printing on a background thread. -raleigh On Sep 12, 2009, at 6:18 AM, Gerriet M. Denkmann wrote: On 11 Sep 2009, at 21:28, Corbin Dunn wrote: Hi Gerriet, Have you tried running with Zombies? Yes. Run - Run With Performance Tool - Zombies If so, does that show an overrelease anywhere? No. Can you please log a bug on bugreporter.apple.com if you believe it is a bug in the Apple framework. Please include an isolated test case, if possible (that will greatly speed up investigation into the issue, especially if it is a recent regression). Bug ID# 7218833. thanks, corbin On Sep 10, 2009, at 10:54 PM, Gerriet M. Denkmann wrote: An app which ran without problems on Leopard likes to crash on Snow Leopard (10.6.1) (both in i386 and x86_64). How to crash: print several times; might crash the first time, might crash the seventh time, but crash it will. The backtrace and the location of the crash varies wildly. In almost always it is some NSFont method. The backtrace below is an exception. But still related to layout stuff. I have a very strong feeling, that something (my code? Apple's printing code?) corrupts some memory which then results in random errors. Or maybe not: just ran it a dozen times with GuardMalloc and it refused to crash. And GuardMalloc did not report any problems. So maybe it is some timing problem with multiple threads? I tried it more than a dozen times with: setCanSpawnSeparateThread: NO and it did not crash. Are there any known problems with printing using setCanSpawnSeparateThread: YES? == the code - (IBAction)printIt: sender ; { (void)sender; ... get path from NSSavePanel NSLog(@%s got path \%...@\,__FUNCTION__, path); NSPrintInfo *printInfo = [ self printInfo ]; [ printInfo setJobDisposition: NSPrintSaveJob ]; NSMutableDictionary *dictionary = [ printInfo dictionary ]; [ dictionary setObject: path forKey: NSPrintSavePath ]; [ dictionary setObject: [ NSNumber numberWithBool: YES ] forKey: NSPrintAllPages ]; NSLog(@%s dictionary %@,__FUNCTION__, dictionary); NSPrintOperation *po = [ NSPrintOperation printOperationWithView: textView printInfo: printInfo ]; [ po setShowsPrintPanel: NO ]; [ po setCanSpawnSeparateThread: YES ]; NSLog(@%s NSPrintOperation %@,__FUNCTION__, po); NSLog(@%s will runOperationModalForWindow for %@,__FUNCTION__, [ textView window ]); [ porunOperationModalForWindow: [ textView window ] delegate: self didRunSelector: @selector ( printOperationDidRun:success:contextInfo: ) contextInfo:NULL ]; NSLog(@%s printing \%...@\,__FUNCTION__, path); } - (void)printOperationDidRun:(NSPrintOperation *)printOperation success:(BOOL)ok contextInfo:(void *)contextInfo { if ( !ok ) // error { NSLog(@%s Error in: runOperationModalForWindow:delegate:didRunSelector:contextInfo :,__FUNCTION__); return; }; NSPrintInfo *printInfo = [ printOperation printInfo ]; NSMutableDictionary *dictionary = [ printInfo dictionary ]; NSString *path = [ dictionary objectForKey: NSPrintSavePath ]; NSLog(@%s printed \%...@\,__FUNCTION__, path); NSLog(@%s printInfo %@,__FUNCTION__, printInfo); return; } == the output -[GymDocument printIt:] got path /private/var/folders/+s/ +sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf -[GymDocument printIt:] dictionary { NSBottomMargin = 41; NSCopies = 1; NSDetailedErrorReporting = 0; NSFaxNumber = ; NSFirstPage = 1; NSHorizonalPagination = 2; NSHorizontallyCentered = 1; NSJobDisposition = NSPrintSaveJob; NSJobSavingFileNameExtensionHidden = 0; NSJobSavingURL = file://localhost/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading%201...4.pdf ; NSLastPage = 2147483647; NSLeftMargin = 18; NSMustCollate = 1; NSOrientation = 0; NSPagesAcross = 1; NSPagesDown = 1; NSPaperName = iso-a4; NSPaperSize = NSSize: {595, 842}; NSPrintAllPages = 1; NSPrintProtected = 0; NSPrintTime = 0001-01-01 06:42:04 +064204; NSPrinter = {\n\Device Description\ = {\n NSDeviceIsPrinter = YES;\n};\n\Language Level\ = 2;\n Name = \ \;\nType = \\;\n}; NSPrinterName = ; NSRightMargin = 18; NSSavePath =
Re: If someone could inspect this code and explain to me what am I doing wrong ?
On Sep 18, 2009, at 07:52, Mario Kušnjer wrote: This code is attempt of implementing a Leopard style source list using a NSOutlineView. Code provided below works but as seen from the console output of NSLog's it displays come cell's number of times which probably means that my implementation of some methods is fault in some part. Also execution is noticeable slow. It's not clear what you think is wrong. Data source methods may be called (in general) any number of times at any time. If you think the NSLog output shows something wrong, post an example here. There's really nothing in your data source code that should be making things slow. If that's an ongoing problem, you should try to narrow down what part of the code is slow. (Performance tools like Instruments may help, but I suspect your application is in too early a phase of development for them to help much. It's probably easier just to try commenting out sections of code to see if things speed up.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Populating TableView Via Button.
Hi, best solution would be to update the datasource... Swapping views just for the sake of displaying new data is not something one should do. Have you read up on how to implement a datasource for NSTableView? Maybe you try to follow this old, but still useful tutorial: http://www.cocoadev.com/index.pl?NSTableViewTutorial Volker Am 18.09.2009 um 16:44 schrieb Sean Kline: Would an alternative implementation be to have the button click swap in a view with a NSTableView bound to its data source? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
What is the life of the c string returned by NSString's UTF8String method?
I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct? I have a class with some (statically allocated) class variables. In the class's -initialize method, I create a retained NSString. I set one of the class variables to the value returned by -UTF8String (as sent to that retained NSString). I use this char* value in some C calls made from instance methods of the class. The first time an object of the class is instantiated, this works fine. But it seems that for subsequent instances, although the value of the char* pointer remains unchanged, the memory it is pointing to is changed (i.e., no longer a C string representation of the NSString). So, either the NSString has done something with the memory pointed to by the initialized reference (i.e., I can't hold onto the reference as I have been), or somehow the memory is getting corrupt in some other way. I will look into the latter but only if my assumption about the former is correct. TIA. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Menu shortcuts without modifiers?
On 17.09.2009, at 22:26, Ashley Clark wrote: Have you tried looking at the menuHasKeyEquivalent:forEvent:target:action: delegate method on NSMenu? I suppose you could examine the firstResponder status and other state and return NO if you don't want the key to be handled as a key equivalent. Ashley, Thanks for the suggestion, hadn't seen that one, but sadly that doesn't work It appears that when I return NO, the OS will scan the actual menu items and trigger them nonetheless. :-( Cheers, -- Uli Kusterer The witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running Safari from application
On 18.09.2009, at 18:52, Bartosz Białecki wrote: I think so too. So do you know maybe another solution how to open local html file with Safari? No. But you could always use a web view instead? Or maybe there's some sort of shared folder somewhere? Cheers, -- Uli Kusterer The witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
On Sep 18, 2009, at 11:04 AM, Stuart Malin wrote: I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct? If I read the documentation, I get a different impression: === The returned C string is automatically freed just as a returned object would be released; you should copy the C string if it needs to store it outside of the autorelease context in which the C string is created === To me that indicates that the returned string may be autoreleased before the NSString is released. Jesper I have a class with some (statically allocated) class variables. In the class's -initialize method, I create a retained NSString. I set one of the class variables to the value returned by -UTF8String (as sent to that retained NSString). I use this char* value in some C calls made from instance methods of the class. The first time an object of the class is instantiated, this works fine. But it seems that for subsequent instances, although the value of the char* pointer remains unchanged, the memory it is pointing to is changed (i.e., no longer a C string representation of the NSString). So, either the NSString has done something with the memory pointed to by the initialized reference (i.e., I can't hold onto the reference as I have been), or somehow the memory is getting corrupt in some other way. I will look into the latter but only if my assumption about the former is correct. TIA. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jsbache%40adobe.com This email sent to jsba...@adobe.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
On 9/18/09 2:04 PM, Stuart Malin said: I have a class with some (statically allocated) class variables. In the class's -initialize method, I create a retained NSString. I set one of the class variables to the value returned by -UTF8String (as sent to that retained NSString). I use this char* value in some C calls made from instance methods of the class. It would be much safer to just call -UTF8String as needed. Or have you found that it is a bottleneck in your code? -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
On Sep 18, 2009, at 11:04 AM, Stuart Malin wrote: I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct? No. The pointer returned is, effectively, autoreleased, and shouldn't be used after the current autorelease pool exits. (I know, it's not an object, but it's actually the -bytes of an autoreleased NSData created by the NSString.) NSString doesn't generally store its contents in UTF-8, so any time you ask for UTF-8 data it has to allocate space for it. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Running Safari from application
On 18.09.2009, at 18:52, Bartosz Białecki wrote: I think so too. So do you know maybe another solution how to open local html file with Safari? You could encode the entire HTML file in a 'data:' URL, if it's not too huge. (You'd have to do the same thing to any custom image: convert it to a data: URL and use that as the src= attribute.) Usually people just embed their own UIWebView if they want to display custom local HTML content. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Finding user's Music folder (and others)?
On Sep 17, 2009, at 9:32 PM, Graham Cox wrote: It's also pretty common to relocate it - don't assume it's unusual. Quite a few people like to keep their music on an external drive so whatever it is you're doing, if you assume ~/Music/, it'll fail in those cases, as you realise. Yes! I've sent bug reports to so many developers of iTunes utilities that hardcode this :P Probably better to work out how to obtain iTunes setting - maybe by peeking at its prefs. Just use NSUserDefaults: $ defaults read com.apple.iApps { iTunesRecentDatabasePaths = ( /Users/Shared/snej/Music/iTunes/iTunes Music Library.xml ); iTunesRecentDatabases = ( file://localhost/Users/Shared/snej/Music/iTunes/iTunes%20Music%20Library.xml ); } —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
On Sep 18, 2009, at 2:20 PM, Sean McBride wrote: On 9/18/09 2:04 PM, Stuart Malin said: I have a class with some (statically allocated) class variables. In the class's -initialize method, I create a retained NSString. I set one of the class variables to the value returned by -UTF8String (as sent to that retained NSString). I use this char* value in some C calls made from instance methods of the class. It would be much safer to just call -UTF8String as needed. Or have you found that it is a bottleneck in your code? Not a bottleneck, merely another case of misguided attempt to optimize. Gotta learn not to do that unless the need is proven. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
On Sep 18, 2009, at 12:04 PM, Stuart Malin wrote: I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct? The only way to be sure is to run Instruments with the object allocations tool and look for allocations equal to the size of the string. But I'm pretty sure that draining the autorelease pool frees the C strings, or at least, they do get cleaned up at some point. In any case, if you want them to stick around, then you need to memcpy () them into a data buffer that is controlled by your application. 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 arch...@mail-archive.com
Re: Handling mouse events in NSCell's?
Ken, Yeah I read the docs. I can't figure out how to get the -stopTracking:at:inView:mouseIsUp: method to fire. Should I just be able to define that method and receive use that method when the mouse is up? Or do I have to use a combination of the mouse tracking methods available. I've tried both and can't figure out why that method does not fire. These are just some random tests to see the order of how I should call the methods. But I can't figure out why that stop method won't fire. Any help would be much appreciated. - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { printf(START TRACKING\n); return NO; } - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp { printf(TRACK); if([self startTrackingAt:NSMakePoint(cellFrame.origin.x,cellFrame.origin.y) inView:controlView]) { //call the continue tracking method here return YES; } return YES; } - (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView { printf(CONTINUE\n); return YES; } - (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { printf(STOP TRACKING); } On Fri, Sep 18, 2009 at 10:11 AM, Raleigh Ledet le...@apple.com wrote: I agree with Ken and strongly encourage you to use the three tracking methods already defined in the NSCell documentation raleigh. On Sep 18, 2009, at 2:12 AM, Ken Ferry wrote: Hi Aaron, You should take a look at the NSCell docshttp://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/trackMouse:inRect:ofView:untilMouseUp: . -Ken trackMouse:inRect:ofView:untilMouseUp: Discussion This method is *generally not overridden* because the default implementation invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the * untilMouseUp* flag. If *untilMouseUp* is set to YES, this method returns YES if the mouse button goes up while the cursor is anywhere; NO, otherwise. If * untilMouseUp* is set to NO, this method returns YES if the mouse button goes up while the cursor is within *cellFrame*; NO, otherwise. This method first invokes *startTrackingAt:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/startTrackingAt:inView:. If that method returns YES, then as mouse-dragged events are intercepted, * continueTracking:at:inView:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/continueTracking:at:inView: is invoked until either the method returns NO or the mouse is released. Finally, *stopTracking:at:inView:mouseIsUp:*http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html#//apple_ref/occ/instm/NSCell/stopTracking:at:inView:mouseIsUp: is invoked if the mouse is released. If *untilMouseUp* is YES, it’s invoked when the mouse button goes up while the cursor is anywhere. If *untilMouseUp * is NO, it’s invoked when the mouse button goes up while the cursor is within *cellFrame*. You usually override one or more of these methods to respond to specific mouse events. On Fri, Sep 18, 2009 at 1:33 AM, aaron smith beingthexemplaryli...@gmail.com wrote: What's the proper way of handling simple mouse events in NSCell's? Like mouseUp, mouseDown, etc. I see that an NSControl implements NSResponder, but wasn't sure if that's the right way to do it. Because of the fact that tables usually use cell's rather than a control. I've also been looking at the method trackMouse:inRect:ofView:untilMouseUp: but this method doesn't ever get fired when the mouse is up. Any ideas? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com This email sent to kenfe...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com This email sent to le...@apple.com ___ Cocoa-dev mailing list
Re: Crash on SL in com.apple.DesktopServices after using NSOpenPanel
On Tue, Sep 8, 2009 at 7:53 AM, Corbin Dunn corb...@apple.com wrote: On Sep 7, 2009, at 5:25 AM, Markus Spoettl wrote: On Sep 7, 2009, at 1:31 PM, Thomas Clement wrote: Looks like an Apple bug. http://kb2.adobe.com/cps/506/cpsid_50654.html That doesn't seem to be the problem with that user's machine as the files are local. It is more than likely that it is the same problem. Please report bugs like this using bugreporter.apple.com -- especially when you believe the problem may be in a system framework. I've also seen this crash - I believe it has something to do with having file sharing on. I've reported it as Radar 7222081 Lucien ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
Le 18 sept. 2009 à 20:20, Nick Zitzmann a écrit : On Sep 18, 2009, at 12:04 PM, Stuart Malin wrote: I am under the impression that the reference returned by NSString's UTF8String method is valid for the life of the NSString instance which provided the reference (and further, that the memory of the referenced C string is freed when the NSString is released). Is this correct? The only way to be sure is to run Instruments with the object allocations tool and look for allocations equal to the size of the string. But I'm pretty sure that draining the autorelease pool frees the C strings, or at least, they do get cleaned up at some point. In any case, if you want them to stick around, then you need to memcpy() them into a data buffer that is controlled by your application. Or to avoid a copy and raw memory management, you can also query directly an NSData from the string using -[NSString dataUsingEncoding:NSUTF8StringEncoding] and then use -[NSData bytes] as the returned value for this method is guarantee to have the same life as the NSData object. -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
getting accessor method info in a different class.
In one class, I have set webView up like this... which works fine, but i want to have access to this pointer from another class... i am not getting something correct here, it gives me warning: WebView may not respond to webView i'll just include the relevant code. what am i not understanding about accessor methods? what is the proper way to have access to the pointer of the webView but in a different class.. the webviewcontroller class works as it should, (the .m file has the @synthesize in it) but the bookmarkcontroller class returns the warning above. (some extra stuff is added like @class to see if it would help) Jon. header of class webviewcontroller: - #import Cocoa/Cocoa.h #import WebKit/WebKit.h @interface webViewController : NSDocument { IBOutlet WebView *webView; } @property(readwrite,retain) WebView *webView; @end - header of class BookMarkController: - #import Cocoa/Cocoa.h #import WebKit/WebKit.h #import webViewController.h @class WebView; @interface BookMarkController : NSWindowController { WebView *theWebView; } @end - implementation of class BookMarkController: - #import BookMarkController.h @implementation BookMarkController - (void)setup { [theWebView webView]; // here i get the warning; } @end - ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: What is the life of the c string returned by NSString's UTF8String method?
Or to avoid a copy and raw memory management, you can also query directly an NSData from the string using -[NSString dataUsingEncoding:NSUTF8StringEncoding] and then use -[NSData bytes] as the returned value for this method is guarantee to have the same life as the NSData object. Though of course you must then beware the GC. Wade ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Problem with fontDescriptorWithFontAttributes:
Not sure if it's a known issue but given this: currentFontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:fontAttributes]; NSFont *fontToUse = [NSFont fontWithDescriptor:currentFontDescriptor size:[[self font] pointSize]]; I'm getting this in the debugger: (gdb) po currentFontDescriptor NSCTFontDescriptor 0x2b0fe0 = { NSFontColorAttribute = NSCalibratedWhiteColorSpace 0 1; NSFontNameAttribute = LucidaGrande; NSFontSizeAttribute = 11; } (gdb) po [fontToUse fontDescriptor] NSCTFontDescriptor 0x269460 = { NSFontNameAttribute = LucidaGrande; NSFontSizeAttribute = 11; } As a result, I can't set the font color. What am I doing wrong? This is with 10.5 as base SDK. Anybody has any idea? -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org Logiciels Nemesys Software laurent.daude...@verizon.net Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Menu shortcuts without modifiers?
On Sep 17, 2009, at 12:29 PM, Uli Kusterer wrote: Hi, I have an app that contains a QTMovieView. I've set things up so people can use the arrow keys to skip, fast forward, rewind, use space to play/pause etc., as they're used to from other movie- playing apps. Now, I'd like to add menu items that correspond to these actions for people who don't know the shortcuts. I'd also like to show the shortcuts in the menu items, so people know the shortcuts are there. Trouble is: If I set e.g. the space key as a menu item's shortcut and a text field has keyboard focus, the space key goes to the menu, not to the text field. I don't want to disable the menu item, as even if there's a text field with keyboard focus, the user may want to use the menu to pause etc. Is there a way to make any control get the shortcut *before* the menus? Is there a way to disable only the shortcut, but still have it displayed? Is there a way to fake the shortcut, so I can do the actual handling at a different level? (Carbon lets you set the menu shortcut glyph separately from the actual shortcut, for example). Anyone have an idea for a solution? Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de Hi Uli, For key events without modifiers, like hitting the spacebar, the first responder of the key window should get first crack via keyDown:. So I'm not sure why you're seeing the behavior you describe. I wrote a quick test with a focused text field in the key window and a main menu item with Space as its key equivalent, and the text field won for spacebar. Can you post the backtrace of the call to the action method of your menu item? It's possible it's being invoked from some place other than -[NSApplication handleKeyEquivalent:]. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
access to object from a different class
Ok, I did not get the desired result, but i am a little closer, I'm going to set this up again. below is example code to set up the circumstance, so you better see what i want to do. (stripped down to what i am trying to find out) (webView is hooked up in IB to a WebView object) (i want to replace the with something that would work where theWebView is pointing to the same thing as webView from the first class a pointer to the current WebView object) In first class, I have set webView up like this... which works fine, but i want to have access to this current webView object from a different class how does one go about getting at the instance webView coding wize??? Jon. header of class WebViewController: - #import Cocoa/Cocoa.h #import WebKit/WebKit.h @interface WebViewController : NSDocument { IBOutlet WebView *webView; } @property(readwrite,retain) WebView *webView; @end - implementation of class WebViewController: - #import WebViewController.h @implementation WebViewController @synthesize webView; @end - header of class BookMarkController: - #import Cocoa/Cocoa.h #import WebKit/WebKit.h #import WebViewController.h @class WebView; @interface BookMarkController : NSWindowController { WebViewController *aController; WebView *theWebView; } @end - implementation of class BookMarkController: - #import BookMarkController.h @implementation BookMarkController - (void)setup { theWebView = ? (i want to point to the same thing as webView's pointer to it's instance) or basically theWebView = webView; } @end - ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: getting accessor method info in a different class.
jon wrote: In one class, I have set webView up like this... which works fine, but i want to have access to this pointer from another class... i am not getting something correct here, it gives me warning: WebView may not respond to webView i'll just include the relevant code. what am i not understanding about accessor methods? what is the proper way to have access to the pointer of the webView but in a different class.. It has nothing to do with accessor methods, except in the most general sense. You haven't imported the header WebView.h in the .m implementation where you're invoking the -webView method. All you've done is @class WebView, which does nothing more than tell the compiler that the name belongs to a class. The compiler doesn't know any methods defined by that class until you import the actual WebView.h header. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iPhone Segmentation Fault
all, My iPhone app is reporting a segmentation fault when terminating (only on the real device, not in the simulator) and also reporting a bad file descriptor. Anyone have any idea what the message is trying to tell me or how to find out. It occurs after the call to dealloc has completed. thanks, Bob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: access to object from a different class
Added info: i would try this: theWebView = [aController webView];except that the aController is new, and not pointing to the thing i want, the first webView's pointer to it's object instance... Jon. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Crash on SL in com.apple.DesktopServices after using NSOpenPanel
On Sep 18, 2009, at 10:30 PM, Lucien W. Dupont wrote: On Tue, Sep 8, 2009 at 7:53 AM, Corbin Dunn corb...@apple.com wrote: On Sep 7, 2009, at 5:25 AM, Markus Spoettl wrote: On Sep 7, 2009, at 1:31 PM, Thomas Clement wrote: Looks like an Apple bug. http://kb2.adobe.com/cps/506/cpsid_50654.html That doesn't seem to be the problem with that user's machine as the files are local. It is more than likely that it is the same problem. Please report bugs like this using bugreporter.apple.com -- especially when you believe the problem may be in a system framework. I've also seen this crash - I believe it has something to do with having file sharing on. I've reported it as Radar 7222081 For what it's worth, the user who reported the crash - which he could reproduce 100% of the time - says that 10.6.1 fixed the issue. Regards Markus -- __ Markus Spoettl smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iPhone Segmentation Fault
Bill, No crash log, just some console messages. Fri Sep 18 15:17:42 unknown com.apple.launchd[1] Notice: (UIKitApplication:com..[0x2e72]) Bug: launchd_core_logic.c:2649 (23909):10 Fri Sep 18 15:17:42 unknown com.apple.launchd[1] Notice: (UIKitApplication:com..[0x2e72]) Working around 5020256. Assuming the job crashed. Fri Sep 18 15:17:42 unknown com.apple.launchd[1] Warning: (UIKitApplication:com..[0x2e72]) Job appears to have crashed: Segmentation fault Fri Sep 18 15:17:42 unknown com.apple.debugserver-43[265] Warning: 1 [0109/1603]: error: ::read ( 7, 0x28091c, 1024 ) = -1 err = Bad file descriptor (0x0009) Fri Sep 18 15:17:42 unknown SpringBoard[24] Warning: Application 'Y' exited abnormally with signal 11: Segmentation fault Bob On Sep 18, 2009, at 3:00 PM, Bill Bumgarner wrote: Got a crash log? On Sep 18, 2009, at 2:57 PM, Bob Barnes wrote: all, My iPhone app is reporting a segmentation fault when terminating (only on the real device, not in the simulator) and also reporting a bad file descriptor. Anyone have any idea what the message is trying to tell me or how to find out. It occurs after the call to dealloc has completed. thanks, Bob ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/bbum%40mac.com This email sent to b...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: If someone could inspect this code and explain to me what am I doing wrong ?
On 2009.09.18, at 19:54, Quincey Morris wrote: It's not clear what you think is wrong. Data source methods may be called (in general) any number of times at any time. If you think the NSLog output shows something wrong, post an example here. Hi again ! I am posting NSLog output and I add some of my questions and comments. I expanded items by clicking the disclosure triangle: - [Session started at 2009-09-18 22:20:58 +0200.] 2009-09-18 22:20:59.030 LSOutline[244:10b] 1 - item number of children is 2 2009-09-18 22:20:59.156 LSOutline[244:10b] 2 - item at index 0 is { listOfShowsRundownLists = ( MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ); nameOfShow = NEWS AT 6; } 2009-09-18 22:20:59.160 LSOutline[244:10b] 3 - item is expandable 2009-09-18 22:20:59.162 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- This is where the value of the first item is called 2009-09-18 22:20:59.169 LSOutline[244:10b] 2 - item at index 1 is { listOfShowsRundownLists = ( MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ); nameOfShow = NEWS AT 10; } 2009-09-18 22:20:59.172 LSOutline[244:10b] 3 - item is expandable 2009-09-18 22:20:59.174 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- and here of the second item. 2009-09-18 22:20:59.380 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- So why is it called again here for the first item, 2009-09-18 22:20:59.384 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- and here for second ? 2009-09-18 22:21:02.768 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- Now I hovered mouse pointer over the disclosure triangle and click it and this gets called first time. 2009-09-18 22:21:02.867 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called second time. 2009-09-18 22:21:02.934 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called third time. 2009-09-18 22:21:03.001 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called fourth time. 2009-09-18 22:21:03.067 LSOutline[244:10b] 1.1 - item number of children is 7 2009-09-18 22:21:03.070 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 0 is MONDAY 2009-09-18 22:21:03.088 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.094 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 1 is TUESDAY 2009-09-18 22:21:03.097 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.103 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 2 is WEDNESDAY 2009-09-18 22:21:03.122 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.125 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 3 is THURSDAY 2009-09-18 22:21:03.127 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.130 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 4 is FRIDAY 2009-09-18 22:21:03.136 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.155 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 5 is SATURDAY 2009-09-18 22:21:03.158 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.161 LSOutline[244:10b] 2.1 - item for key listOfShowsRundownLists at index 6 is SUNDAY 2009-09-18 22:21:03.163 LSOutline[244:10b] 3.1 - item is not expandable 2009-09-18 22:21:03.174 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- Probable after going through the array of children, parent has to be called again 2009-09-18 22:21:03.191 LSOutline[244:10b] 4.1 - item is MONDAY 2009-09-18 22:21:03.217 LSOutline[244:10b] 4.1 - item is TUESDAY 2009-09-18 22:21:03.221 LSOutline[244:10b] 4.1 - item is WEDNESDAY 2009-09-18 22:21:03.227 LSOutline[244:10b] 4.1 - item is THURSDAY 2009-09-18 22:21:03.229 LSOutline[244:10b] 4.1 - item is FRIDAY 2009-09-18 22:21:03.234 LSOutline[244:10b] 4.1 - item is SATURDAY 2009-09-18 22:21:03.236 LSOutline[244:10b] 4.1 - item is SUNDAY 2009-09-18 22:21:03.251 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- Probable after going through the array of children, parent has to be called again 2009-09-18 22:21:27.193 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- Now I hovered mouse pointer over the disclosure triangle and this gets called first time. 2009-09-18 22:21:27.261 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- And this gets called second time. 2009-09-18 22:21:27.328 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- And this gets called third time. 2009-09-18 22:21:27.396 LSOutline[244:10b] 4 - item for key
transition through black
hello, I want to create a CATransition for transition as follows : first, fade to black second fade to new image How should I do this ? -- erik ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: transition through black
On 19 Sep 2009, at 01:15, Christopher Kemsley wrote: CAKeyframeAnimation Have three keyframes: 1) original image 2) black image (from CGBitmapContext and CGFillRect... etc) 3) new image hmmm... that might be a solution... however I was thinking about using CIFilter with CATransition for this. any idea ? thanx -- erik ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: If someone could inspect this code and explain to me what am I doing wrong ?
On Sep 18, 2009, at 5:26 PM, Mario Kušnjer wrote: This is slow while expanding and collapsing. Maybe because it is writing to the NSLog ? Well, did you try commenting out the logs and see if that reduces the slowness? Charles___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Static Analyzer and Core Foundation
Folks; Alert - potential boneheaded-ness lies ahead - please be gentle. I'll be the first to admit that I'm much happier in ObjC than C… I thought I would try static analysis and see what turned up. On the whole I must say I'm pleased but this one has me questioning my basic understanding if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { … 41 } else { 42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); 43 if ( mdi != nil ) { 44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, MDItemCopyAttributeNames(mdi)); … CFRelease(dictRef); } else { … handle error } } Static Analysis tells me I have a potential leak of object allocated on line 44 -- that's all. My questions are: 1) Why is there not a warning for the object allocated on line 42 - mdi ? 2) Why is the CFRelease(dictRef) not sufficient? Thank you for you patience! Steve___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
Line 44 creates 2 objects, one goes into the dictRef, the other is not assigned to a variable, but is used only as the second argument to MDItemCopyAttributes. The object that you create inside that call is never released. Luke On Sep 18, 2009, at 4:33 PM, Steve Cronin wrote: Folks; Alert - potential boneheaded-ness lies ahead - please be gentle. I'll be the first to admit that I'm much happier in ObjC than C… I thought I would try static analysis and see what turned up. On the whole I must say I'm pleased but this one has me questioning my basic understanding if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { … 41 } else { 42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); 43 if ( mdi != nil ) { 44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, MDItemCopyAttributeNames(mdi)); … CFRelease(dictRef); } else { … handle error } } Static Analysis tells me I have a potential leak of object allocated on line 44 -- that's all. My questions are: 1) Why is there not a warning for the object allocated on line 42 - mdi ? 2) Why is the CFRelease(dictRef) not sufficient? Thank you for you patience! Steve___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com This email sent to luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
Luke; OK thank-you for that answer to question 2! Any thoughts on question 1? Steve On Sep 18, 2009, at 6:36 PM, Luke the Hiesterman wrote: Line 44 creates 2 objects, one goes into the dictRef, the other is not assigned to a variable, but is used only as the second argument to MDItemCopyAttributes. The object that you create inside that call is never released. Luke On Sep 18, 2009, at 4:33 PM, Steve Cronin wrote: Folks; Alert - potential boneheaded-ness lies ahead - please be gentle. I'll be the first to admit that I'm much happier in ObjC than C… I thought I would try static analysis and see what turned up. On the whole I must say I'm pleased but this one has me questioning my basic understanding if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { … 41 } else { 42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); 43 if ( mdi != nil ) { 44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, MDItemCopyAttributeNames(mdi)); … CFRelease(dictRef); } else { … handle error } } Static Analysis tells me I have a potential leak of object allocated on line 44 -- that's all. My questions are: 1) Why is there not a warning for the object allocated on line 42 - mdi ? 2) Why is the CFRelease(dictRef) not sufficient? Thank you for you patience! Steve___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com This email sent to luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
On 18 Sep 2009, at 4:33 PM, Steve Cronin wrote: Alert - potential boneheaded-ness lies ahead - please be gentle. I'll be the first to admit that I'm much happier in ObjC than C… I thought I would try static analysis and see what turned up. On the whole I must say I'm pleased but this one has me questioning my basic understanding if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { … 41 } else { 42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); 43 if ( mdi != nil ) { 44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, MDItemCopyAttributeNames(mdi)); … CFRelease(dictRef); } else { … handle error } } Static Analysis tells me I have a potential leak of object allocated on line 44 -- that's all. My questions are: 1) Why is there not a warning for the object allocated on line 42 - mdi ? Seems like it should be; you're not releasing it and it's going out of scope. 2) Why is the CFRelease(dictRef) not sufficient? In this case, it's probably complaining about the MDItemCopyAttributeNames() call, which (because it has Copy in the name) returns an object you'd have to release. I.e., line 44 allocates two objects, the dictionary which you *are* releasing and the attribute names array, which you're not. .chris -- Chris Parker Apple Inc. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
There's not enough code here to give a good answer to question 1. Luke On Sep 18, 2009, at 4:39 PM, Steve Cronin wrote: Luke; OK thank-you for that answer to question 2! Any thoughts on question 1? Steve On Sep 18, 2009, at 6:36 PM, Luke the Hiesterman wrote: Line 44 creates 2 objects, one goes into the dictRef, the other is not assigned to a variable, but is used only as the second argument to MDItemCopyAttributes. The object that you create inside that call is never released. Luke On Sep 18, 2009, at 4:33 PM, Steve Cronin wrote: Folks; Alert - potential boneheaded-ness lies ahead - please be gentle. I'll be the first to admit that I'm much happier in ObjC than C… I thought I would try static analysis and see what turned up. On the whole I must say I'm pleased but this one has me questioning my basic understanding if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { … 41 } else { 42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); 43 if ( mdi != nil ) { 44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, MDItemCopyAttributeNames(mdi)); … CFRelease(dictRef); } else { … handle error } } Static Analysis tells me I have a potential leak of object allocated on line 44 -- that's all. My questions are: 1) Why is there not a warning for the object allocated on line 42 - mdi ? 2) Why is the CFRelease(dictRef) not sufficient? Thank you for you patience! Steve___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/luketheh %40apple.com This email sent to luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
Luke; I've adapted the code to accomodate your's and Chris' answer to question 2. Here's the entire method, which now shows not static analyzer issues but I still would like to understand why not. + (NSDictionary *)metadataForFilePath:(NSString *)thisPath { NSDictionary *md = [NSDictionary dictionary]; if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) { NSLog(@file does not existl); } else { MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath ); if ( mdi != nil ) { CFArrayRef arrayRef = MDItemCopyAttributeNames(mdi); CFDictionaryRef dictRef = MDItemCopyAttributes( mdi, arrayRef); md = [NSDictionary dictionaryWithDictionary:(NSDictionary *)dictRef]; CFRelease(dictRef); CFRelease(arrayRef); } else { NSLog(@mdi is nil); } } return md; } Is this the 'best' this can be? Thanks for helping me learn, Steve On Sep 18, 2009, at 6:44 PM, Luke the Hiesterman wrote: There's not enough code here to give a good answer to question 1. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSString vs. encoding
Op 17 sep 2009, om 22:29 heeft Andrew Farmer het volgende geschreven: On 16 Sep 2009, at 22:55, Johan Kool wrote: Thanks so much!! That is indeed the case! I now use strunvis and it's all done in just 4 lines of code. (Well, except that I should still handle a returned error code.) int len = [stringA lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; char dst[len]; strunvis(dst, [stringA UTF8String]); return [NSString stringWithUTF8String:dst]; Not to burst your bubble, but that doesn't look quite right. It fails in the case where stringA contains no escaped characters (including the case where it's empty) -- the terminating null byte isn't counted by lengthOfBytesUsingEncoding:, so it ends up writing one byte off the end of dst[]. Ok, thanks for pointing that out. I'll just increase len by 1, that way it should always fit. Johan --- http://www.johankool.nl/ KOOLISTOV - Software for Mac and iPhone http://www.koolistov.net/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: If someone could inspect this code and explain to me what am I doing wrong ?
On Sep 18, 2009, at 15:26, Mario Kušnjer wrote: 2009-09-18 22:20:59.174 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- and here of the second item. 2009-09-18 22:20:59.380 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- So why is it called again here for the first item, 2009-09-18 22:20:59.384 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 10 --- and here for second ? 2009-09-18 22:21:02.768 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- Now I hovered mouse pointer over the disclosure triangle and click it and this gets called first time. 2009-09-18 22:21:02.867 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called second time. 2009-09-18 22:21:02.934 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called third time. 2009-09-18 22:21:03.001 LSOutline[244:10b] 4 - item for key nameOfShow is NEWS AT 6 --- And this gets called fourth time. I see what you mean, but this is *not* obviously wrong. It's possible, for example, that this is related to animating the rotation of the disclosure triangle when you clicked it (I think it used to rotate in 3 steps, haven't looked recently). I think you should expect that the data source method calls *won't* be optimal when looked at this way. Those methods are typically supposed to be inexpensive, for exactly that reason. Yours looked plenty inexpensive enough. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: If someone could inspect this code and explain to me what am I doing wrong ?
On 19/09/2009, at 8:26 AM, Mario Kušnjer wrote: Maybe because it is writing to the NSLog ? Almost certainly. There's no other obvious bottleneck in your code, but logging is quite slow, and if done during any kind of drawing, will really be noticeable. A table/outline's data source is called frequently while the table is being redrawn. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Printing to NSData
I am doing: NSPrintOperation *po = [ NSPrintOperation printOperationWithView: textView printInfo: printInfo ]; ... PDFDocument *pdfFile = [ [ PDFDocument alloc ] initWithURL: pdfUrl ]; ... do some post-processing here Works fine, but looks rather inefficient, as file-IO is probably the slowest thing which can be done. So I tried: PDFOperationWithView:insideRect:toData:printInfo: (identical printInfo as before) ... PDFDocument *pdfFile = [ [ PDFDocument alloc ] initWithData: pdfData ]; ... do some post-processing here but the result is just one (very long) page. Is this a bug or did I miss some magical incantation here? Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Printing with Snow Leopard
On 19 Sep 2009, at 00:36, Raleigh Ledet wrote: You are printing the same instance of a view that is in your UI. So basically, your are trying to get the same view to print on two threads. Unless your view can handle concurrent drawing, this could be bad. NSTextView doesn't support concurrent drawing. I think you were getting lucky on Leopard. And lucky on Tiger too. Possible solutions: 1. Don't print concurrently. That is my current solution. It blocks the user interface, which is bad, but 1000 pages get printed in well under 20 seconds, so it's not too bad. 2. Create another view and set it up with the content from your UI. Use this view for printing on a background thread. Thanks for this suggestion. I will try it, when the blocking becomes annoying. -raleigh On Sep 12, 2009, at 6:18 AM, Gerriet M. Denkmann wrote: On 11 Sep 2009, at 21:28, Corbin Dunn wrote: Hi Gerriet, Have you tried running with Zombies? Yes. Run - Run With Performance Tool - Zombies If so, does that show an overrelease anywhere? No. Can you please log a bug on bugreporter.apple.com if you believe it is a bug in the Apple framework. Please include an isolated test case, if possible (that will greatly speed up investigation into the issue, especially if it is a recent regression). Bug ID# 7218833. thanks, corbin On Sep 10, 2009, at 10:54 PM, Gerriet M. Denkmann wrote: An app which ran without problems on Leopard likes to crash on Snow Leopard (10.6.1) (both in i386 and x86_64). How to crash: print several times; might crash the first time, might crash the seventh time, but crash it will. The backtrace and the location of the crash varies wildly. In almost always it is some NSFont method. The backtrace below is an exception. But still related to layout stuff. I have a very strong feeling, that something (my code? Apple's printing code?) corrupts some memory which then results in random errors. Or maybe not: just ran it a dozen times with GuardMalloc and it refused to crash. And GuardMalloc did not report any problems. So maybe it is some timing problem with multiple threads? I tried it more than a dozen times with: setCanSpawnSeparateThread: NO and it did not crash. Are there any known problems with printing using setCanSpawnSeparateThread: YES? == the code - (IBAction)printIt: sender ; { (void)sender; ... get path from NSSavePanel NSLog(@%s got path \%...@\,__FUNCTION__, path); NSPrintInfo *printInfo = [ self printInfo ]; [ printInfo setJobDisposition: NSPrintSaveJob ]; NSMutableDictionary *dictionary = [ printInfo dictionary ]; [ dictionary setObject: path forKey: NSPrintSavePath ]; [ dictionary setObject: [ NSNumber numberWithBool: YES ] forKey: NSPrintAllPages ]; NSLog(@%s dictionary %@,__FUNCTION__, dictionary); NSPrintOperation *po = [ NSPrintOperation printOperationWithView: textView printInfo: printInfo ]; [ po setShowsPrintPanel: NO ]; [ po setCanSpawnSeparateThread: YES ]; NSLog(@%s NSPrintOperation %@,__FUNCTION__, po); NSLog(@%s will runOperationModalForWindow for %@,__FUNCTION__, [ textView window ]); [ porunOperationModalForWindow: [ textView window ] delegate: self didRunSelector: @selector ( printOperationDidRun:success:contextInfo: ) contextInfo:NULL ]; NSLog(@%s printing \%...@\,__FUNCTION__, path); } - (void)printOperationDidRun:(NSPrintOperation *)printOperation success:(BOOL)ok contextInfo:(void *)contextInfo { if ( !ok ) // error { NSLog(@%s Error in: runOperationModalForWindow:delegate:didRunSelector:contextInfo :,__FUNCTION__); return; }; NSPrintInfo *printInfo = [ printOperation printInfo ]; NSMutableDictionary *dictionary = [ printInfo dictionary ]; NSString *path = [ dictionary objectForKey: NSPrintSavePath ]; NSLog(@%s printed \%...@\,__FUNCTION__, path); NSLog(@%s printInfo %@,__FUNCTION__, printInfo); return; } == the output -[GymDocument printIt:] got path /private/var/folders/+s/ +sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf -[GymDocument printIt:] dictionary { NSBottomMargin = 41; NSCopies = 1; NSDetailedErrorReporting = 0; NSFaxNumber = ; NSFirstPage = 1; NSHorizonalPagination = 2; NSHorizontallyCentered = 1; NSJobDisposition = NSPrintSaveJob; NSJobSavingFileNameExtensionHidden = 0; NSJobSavingURL = file://localhost/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading%201...4.pdf ; NSLastPage = 2147483647; NSLeftMargin = 18; NSMustCollate = 1; NSOrientation = 0; NSPagesAcross = 1; NSPagesDown = 1; NSPaperName = iso-a4; NSPaperSize = NSSize: {595, 842}; NSPrintAllPages
How to show the Info Panel for the files in tableview?
Hi all, My application is a movie player that similar to iTunes. Now, the result i want are as follows... If I right-click a movie file in the table view and select the info menu item, I expect it can display the Info Panel of the file. Now, the contextual menu is accomplished. But, how can I display the Info Panel? Thanks in advance. James ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to show the Info Panel for the files in tableview?
On 19/09/2009, at 2:17 PM, James wrote: Now, the contextual menu is accomplished. But, how can I display the Info Panel? The question is a bit too broad - break it down. This is the same as displaying any window/dialog/sheet. Try starting with the documentation for NSWindow and NSPanel. The display of this window has nothing to do with your table and/or menu. It can be made to work independently then hooked up to the menu command when you're done. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Optimizing Enormous lists in NSBrowser
On Sep 17, 2009, at 2:32 PM, Dave DeLong wrote: For normal-sized directories, this works pretty well. However, in my worst-case scenario of a flat directory containing 1 million files, I've found that it takes 34.8 seconds to retrieve a full directory listing (so I know how many to return in browser:numberOfRowsInColumn:), 301.5 seconds to filter the array, and another 73.6 seconds to sort it. Have you sampled/profiled it, so you know exactly what operations are slow? (My hunch is that, at that scale, high-level Cocoa conveniences like predicates and NSFileManager are going to add a lot of overhead.) If you want have fast operations for huge directories, you'll need to use lower-level calls, unfortunately. The most efficient call for your purposes is probably getdirentriesattr. There's a good description of it, with sample code, in Advanced Mac OS X Programming (Dalrymple Hillegass.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Static Analyzer and Core Foundation
On Sep 18, 2009, at 5:25 PM, Steve Cronin wrote: Is this the 'best' this can be? You need to call CFRelease on 'mdi', right after releasing 'arrayRef'. I don't know why the analyzer isn't reporting that as a leak — you could file a bug report. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com