Re: How to show progress indicator for background job
On 17/01/2010, at 4:06 PM, Grant Christensen wrote: Hi, apologies for having a wrong topic, replied instead of created a new message. On 16/01/2010, at 11:25 PM, Grant Christensen wrote: Hi all, Somewhat new to cocoa (Mac even) development, and I have a UI layout question that I am hoping to get some opinions on. I have a single window application that contains both a toolbar and a bottom bar. The application periodically goes off and reads some data from a remote server. This is a process that may take up to five seconds, and I don't want to make the user pause while it is occuring, so don't want to pop up a sheet with a status or similar. My first thought was to put a label in the bottom bar saying something like: retrieving from server xxx, and also have a progress indicator. However the apple UI guidelines state not to use any controls in the bottom bar. Can you think of any other Mac standard ways to show progress in a non obtrusive mannor? Just the status label alone may not be sufficient as there would be no way to see if the process has stalled. Thanks for any suggestions Grant Christensen Hi Grant, I don't think there'd be any problem putting a message and a progress bar in the bottom bar. They aren't controls, they're just items which tell the user the state of your app's progress. In fact, both Xcode and Safari do exactly this. In Safari the bottom bar is called a status bar; fairly self explanatory. Ron ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Clipping subview drawing to arbitrary path or image (iPhone)
On Jan 16, 2010, at 21:23:16, David Duncan wrote: I'm not certain where you see that comment, but it is incorrect (with respect to iPhone OS 3.x – the mask property did not exist on 2.x). Scroll to the bottom of this page: http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/LayerVisProps.html#//apple_ref/doc/uid/TP40006074 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 progress indicator for background job
Hi Ron, Thanks for that... I should have thought to check out how Apple did it themselves. I was thinking a status message would be ok, but wasn't sure about the progress bar, but then it could all be handled in a text label anyway... Downloading update... 10% complete. Gant On 17/01/2010, at 6:31 PM, Ron Fleckner wrote: On 17/01/2010, at 4:06 PM, Grant Christensen wrote: Hi, apologies for having a wrong topic, replied instead of created a new message. On 16/01/2010, at 11:25 PM, Grant Christensen wrote: Hi all, Somewhat new to cocoa (Mac even) development, and I have a UI layout question that I am hoping to get some opinions on. I have a single window application that contains both a toolbar and a bottom bar. The application periodically goes off and reads some data from a remote server. This is a process that may take up to five seconds, and I don't want to make the user pause while it is occuring, so don't want to pop up a sheet with a status or similar. My first thought was to put a label in the bottom bar saying something like: retrieving from server xxx, and also have a progress indicator. However the apple UI guidelines state not to use any controls in the bottom bar. Can you think of any other Mac standard ways to show progress in a non obtrusive mannor? Just the status label alone may not be sufficient as there would be no way to see if the process has stalled. Thanks for any suggestions Grant Christensen Hi Grant, I don't think there'd be any problem putting a message and a progress bar in the bottom bar. They aren't controls, they're just items which tell the user the state of your app's progress. In fact, both Xcode and Safari do exactly this. In Safari the bottom bar is called a status bar; fairly self explanatory. Ron --- Grant Christensen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Accessing Variables from Multiple NIBs
On Jan 16, 2010, at 22:08, Jon Buys wrote: Well, before this goes any further, I'm going to go ahead and answer my own question here. The problem is that in the code below, I'm actually instantiating two AppController objects, one in each NIB. So, one AppController doesn't have any idea about the other AppController, and can't get to it's string. The solution I've come up with is to replace my window controller class with a simple call to NSBundle to load the NIB, setting AppController as the owner of the second NIB. Then, in IB, I set the identity of File's Owner to AppController, delete the NSObject, and bind the button to the IBAction in the File's Owner. It's great to solve my own problems, I just wish I'd do it before sending out to Cocoa-Dev for help! Well, your solution may be functional, but there's an easier way -- one that leverages standard behavior. There are two parts to this. The first is to instantiate your singleton AppController object in just one nib file. A good place for this is MainMenu, since you have only one of those. The trick is to connect the Application pseudo-object's delegate outlet to your AppController object. Then in *any* nib file whose contents need to bind to the AppController object, you can refer to Application.delegate (since the Application pseudo-object is available in any nib file, and it always refers to the same object, so its delegate property always refers to your AppController singleton.) That takes care of bindings, typically. However, although you said bind above, you likely meant connect, since bindings are made to a property, not to an IBAction method. For target/action connections, you connect the selector outlet (in the Sent Actions section of the Connections tab) of your buttons or other controls to First Responder in their own nib file, and choose the appropriate AppController selector from the list. Because your AppController is the application's delegate it is therefore in the responder chain, and -- assuming nothing else implements the same selector -- the action will get routed to your AppController without doing anything clever to the nib file's owner. Note that the list of selectors available for the First Responder pseudo-object is an amalgamation of all the IBAction methods known in your Xcode project's header files. So long as you put your AppController IBAction prototypes in your AppController.h file, IB will synchronize with Xcode and know they exist. Note also that changing a window nib's File Owner from a NSWindowController (or a NSDocument, which has similar behavior wrt the nib file) to some other class is not a good idea. NSWindowController, NSDocument and NSViewController all have built-in functionality to manage the ownership of top level nib objects. If your replacement doesn't have similar functionality, you will either leak nib objects or crash with memory management errors. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 progress indicator for background job
On Jan 17, 2010, at 00:58, Grant Christensen wrote: Thanks for that... I should have thought to check out how Apple did it themselves. I was thinking a status message would be ok, but wasn't sure about the progress bar, but then it could all be handled in a text label anyway... Downloading update... 10% complete. While I don't see anything wrong with a small progress bar next to the status message, a circular progress indicator may be more appealing. If it's not extremely important to represent the proportion of the download completed, then an *indeterminate* circular progress indicator's animation is enough to draw attention to the activity represented by the status message, without being a glaring eyesore. (I guess I really mean: without being bright blue.) If it is important, a determinate circular progress indicator, like the one Xcode uses to show build progress, may be more pleasant than a bar. Incidentally, iPhoto, iCal and iTunes all have controls in their bottom bar. So do Mail, Pages and Numbers, in a way. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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] Release Navigation View Controller Question
Hi, I have Navigation based application. When I switch from one view to the next I use the following code. In the below code, is it ok to release browseviewController? BrowseViewController *browseviewController = [[BrowseViewController alloc] initWithNibName:@BrowseViewController bundle:nil]; [browseviewController setTitle:@Browse By Title]; [self.navigationController pushViewController:browseviewController animated:YES]; // ok to release? [browseviewController release]; Thanks, Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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] Release Navigation View Controller Question
Yes, that code is 100% fine. Here's the logic from purely your point of view. You allocate browserviewController and in doing so take ownership. You do some stuff with browserviewController. You are finished with browserviewController, and don't want to do anything else with it, so you resign ownership. From a more global perspective, the navigationController becomes interested in browserviewController when you ask it to push it, and it too takes ownership, so when *you* release, the navigationController still has a handle on the controller, and keeps hold of it until it decides it's done with it. Bob On Sun, Jan 17, 2010 at 10:30 AM, Philip Vallone philip.vall...@verizon.net wrote: Hi, I have Navigation based application. When I switch from one view to the next I use the following code. In the below code, is it ok to release browseviewController? BrowseViewController *browseviewController = [[BrowseViewController alloc] initWithNibName:@BrowseViewController bundle:nil]; [browseviewController setTitle:@Browse By Title]; [self.navigationController pushViewController:browseviewController animated:YES]; // ok to release? [browseviewController release]; Thanks, Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@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: NSTextField sendActionOn:
On 17 Jan 2010, at 04:56, Brad Stone wrote: I tried that (textDidBeginEditing) but it fires only after the user hits a key to begin typing, not when they first enter the field (i.e. the action that makes the focus ring show up). I want to be notified as soon as the user clicks in the field to get the cursor in there. I was able to capture the mouseDown event in the field but only in a subclass which is causing me problems elsewhere. If subclassing is out (for whatever) and your OS X target is 10.6 then you could try observing NSWindow firstResponder. Subclassing is the way to go though IMHO. Regards Jonathan Mitchell Developer http://www.mugginsoft.com On Jan 16, 2010, at 3:08 PM, Matthew Lindfield Seager wrote: On Sunday, January 17, 2010, Brad Stone cocoa-...@softraph.com wrote: The best I can do for the NSTextField is bind an action and in, IB, in the TextFieldAttributes set Action to Sent on End Editing which sends the action after the first character is type. I want the action sent as soon as the field gains focus. Googling nstextfield begin editing notification without the quotes takes one straight to the fine manual. See textDidBeginEditing in particular. Hope that is what you are after. Regards, Matt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jonathan%40mugginsoft.com This email sent to jonat...@mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextField sendActionOn:
On 17/01/2010, at 3:56 PM, Brad Stone wrote: I was able to capture the mouseDown event in the field but only in a subclass which is causing me problems elsewhere. Indeed, a mouse click is not the only reason a field might become focused - the user could tab into it as well. Overriding -becomeFirstResponder should do it. Taking a step back though, WHY do you need to get notified here? What are you trying to do? There might be a better way. --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: [iphone] Release Navigation View Controller Question
Thanks Tom. Great explanation! On Jan 17, 2010, at 6:05 AM, Tom Davie wrote: Yes, that code is 100% fine. Here's the logic from purely your point of view. You allocate browserviewController and in doing so take ownership. You do some stuff with browserviewController. You are finished with browserviewController, and don't want to do anything else with it, so you resign ownership. From a more global perspective, the navigationController becomes interested in browserviewController when you ask it to push it, and it too takes ownership, so when *you* release, the navigationController still has a handle on the controller, and keeps hold of it until it decides it's done with it. Bob On Sun, Jan 17, 2010 at 10:30 AM, Philip Vallone philip.vall...@verizon.net wrote: Hi, I have Navigation based application. When I switch from one view to the next I use the following code. In the below code, is it ok to release browseviewController? BrowseViewController *browseviewController = [[BrowseViewController alloc] initWithNibName:@BrowseViewController bundle:nil]; [browseviewController setTitle:@Browse By Title]; [self.navigationController pushViewController:browseviewController animated:YES]; // ok to release? [browseviewController release]; Thanks, Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@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
NSDrawNinePartImage crash, autorelease sent to freed object
hey there i have written a chat client as part of an app i am developing that uses a subclassed NSTextView to draw bubbles around messages, in the iChat style. this works well for me and a few hundred other users, except for one who reports that any time a message is entered the application crashes. the top of the crash report is below: OS Version: Mac OS X 10.5.7 (9J61) Report Version: 6 Anonymous UUID: 0C0AAFBF-22FE-4D33-81D3-A15E1A2D0124 Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0001, 0x Crashed Thread: 0 Application Specific Information: objc[79810]: FREED(id): message autorelease sent to freed object=0x15fa3250 Thread 0 Crashed: 0 libobjc.A.dylib 0x9068fbfa _objc_error + 116 1 libobjc.A.dylib 0x9068fc30 __objc_error + 52 2 libobjc.A.dylib 0x9068e637 _freedHandler + 58 3 com.apple.AppKit 0x92cd7c83 _NSTileImageWithOperation + 2061 4 com.apple.AppKit 0x92cf4902 _NSDrawNinePartImage + 1128 5 com.apple.AppKit 0x92f26f2c NSDrawNinePartImage + 575 6 com.bdp.iSoul 0x0002ff61 -[BubbleTextView drawBubbleAroundTextInRect:user:outgoing:] + 1913 7 com.bdp.iSoul 0x0003097d -[BubbleTextView drawViewBackgroundInRect:] + 1322 i am not sure how to go about fixing this, can anyone suggest where the autorelease message is sent? the tiled bubble images are held in NSArrays and the bubble drawing code in BubbleTextView is shown below. i cannot understand why the error would occur for this user particularly, can anyone see something wrong with the code? - (void)drawBubbleAroundTextInRect:(NSRect)rect user:(User *)user outgoing:( BOOL)outgoing { NSArray *balloon; NSAffineTransform *aft = [NSAffineTransform transform]; if (outgoing) { balloon = blueBalloon; // if outgoing, flip the co-ordinates for the balloon [aft scaleXBy:-1 yBy:1]; [aft translateXBy:-(2 * rect.origin.x + rect.size.width) yBy:0]; [aft concat]; } else { ... } // adjust the paragraph rectangle to contain the balloon NSRect balloonRect = NSMakeRect(rect.origin.x - kBalloonPadLeft, rect.origin.y - kBalloonPadTop, rect.size.width + kBalloonPadLeft + kBalloonPadRight, rect.size.height + kBalloonPadTop + kBalloonPadBottom); NSDrawNinePartImage(balloonRect, [balloon objectAtIndex:0], [balloon objectAtIndex:1], [balloon objectAtIndex:2], [balloon objectAtIndex:3], [balloon objectAtIndex:4], [balloon objectAtIndex:5], [balloon objectAtIndex:6], [balloon objectAtIndex:7], [balloon objectAtIndex:8], NSCompositeSourceOver, 1.0, YES); [aft invert]; [aft concat]; // now draw the icon, will not be flipped NSImage *icon; if ([user icon]) { icon = [[NSImage alloc] initWithData:[user icon]]; [icon autorelease]; } else { icon = [NSImage imageNamed:@PrefAccount]; } NSPoint iconOrigin = NSMakePoint(balloonRect.origin.x - kIconBuffer - kIconSize, balloonRect.origin.y + balloonRect.size.height); if (outgoing) iconOrigin.x += kIconSize; [icon compositeToPoint:iconOrigin operation:NSCompositeSourceOver]; [aft invert]; [aft concat]; // now draw the username NSRect usernameRect; NSSize usernameSize = [[user name] sizeWithAttributes:usernameAttributes]; NSRect ourFrame = [self frame]; if (outgoing) { CGFloat endPoint = ourFrame.origin.x + ourFrame.size.width - kIconBuffer; CGFloat startPoint = MAX(ourFrame.origin.x + kIconBuffer, endPoint - usernameSize.width); usernameRect = NSMakeRect(startPoint, iconOrigin.y, endPoint - startPoint, kUsernameHeight); } else { usernameRect = NSMakeRect(iconOrigin.x, iconOrigin.y, MIN(usernameSize.width, ourFrame.size.width - kIconBuffer), kUsernameHeight); } [[user name] drawInRect:usernameRect withAttributes:usernameAttributes]; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Can a model key path binding access a super class property
Hi all, I have two classes, one defining a few base properties, and another more specific class inheriting from it. Example below: @interface BBSBaseClass : NSObject { NSString*aValue; } @property (readwrite, copy) NSString*aValue; @end @interface BBSMoreSpecific : BBSBaseClass { NSString*anotherValue; } @property (readwrite, assign) NSString *anotherValue; @end In my window I have a NSTableView that is using an array controller to get access to my data. The array controller is bound to an array of BBSMoreSpecific classes. The problem I am having is that all of my columns bound to the fields in the BBSMoreSpecific class show their data, but those bound to those in the base class do not. I am using a simple model key path of just the name of the ivar, so aValue and anotherValue. Can the bindings access the base class or can they only access values in the class the array controller is directly connected to? regards, --- Grant Christensen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSURLRequest and NSOperationQueue
Dave, If you are setting up NSURLConnection on an NSOperation, I would suggest you keep the operation around as you get the data back. The symptom you describe, sounds like you are starting the NSURLConnection, but then you leave your main method in the NSOperation you created. This essentially orphans the thread that the NSURLConnection needs to report back progress to your delegate. If that Thread no longer exists, the NSURLConnection will never report back. Solution 1 would be to have you do a synchronous NSURLConnection in your main method. This will show you everything is working in that thread and that you do indeed get data back from your server. Solution 2 would be to change your NSOperation main method such that you start the NSURLConnection asynchronously, and you will need to loop until either you receive the connection:didFailWithError: delegate callback or you receive the connectionDidFinishLoading: delegate method callback. Since you're creating a NSOperation anyway, you probably want threaded access to your data. So I would work on solution #2. Your main method in your NSOperation subclass should be something simple like the following: NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop]; if ( currentRunLoop ) { // 1. Start the URLConnection! mURLConnection = [NSURLConnection connectionWithRequest:mURLRequest delegate:self]; [mURLConnection start]; // 2. We have a run Loop, so wait until the connection is finished while ( !done ![self isCancelled] ) { // Run the RunLoop! NSDate* dateLimit = [[NSDate date] addTimeInterval:0.1]; [currentRunLoop runUntilDate:dateLimit]; } // 3. Report your results to your main thread! ... } Scott Tury On Jan 17, 2010, at 12:08 AM, cocoa-dev-requ...@lists.apple.com wrote: Subject: NSURLRequest and NSOperationQueue Hi everyone, I'm building an object that communicates with a server. For various reasons, I'd like to queue up all the NSURLRequests in an NSOperationQueue so that I never have more than one connection open at a time. However, I'm running into a weird issue. If I create my NSURLRequest and open an NSURLConnection directly, then the connection works and everything proceeds as expected. However, if I create an NSInvocationOperation to delay the creation of the connection until the queue is idle, then the connection is created (and is non-nil), but the URLRequest never triggers any of its delegate methods. After some investigation, I realized that the operation was executing on a different thread, so I scheduled the URLConnection on the mainRunLoop in the default mode (after unscheduling from the currentRunLoop). I'm also retaining the URLConnection in an ivar, but it's still not firing any delegate methods (on any thread). Any ideas why my URL connection isn't working? Thanks, Dave DeLong ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 in display of leopard app on snowleopard
Hi All, I have encountered a veered problem (or I am not able to understand). I have developed an App (using NSImageView, NSView, NSProgressIndicator etc.) using Base SDK Mac OS X 10.5. And it works fine on leopard. But when I run the App on Snow Leopard the App (User interface) looks more dull (or whitish where my enabled button also look like disabled) in color. Any idea how to over come this problem with out changing the Base SDK from 10.5 to 10.6. Regards Cocoa.learner ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSURLRequest and NSOperationQueue
Solution 1 would be to have you do a synchronous NSURLConnection in your main method. This will show you everything is working in that thread and that you do indeed get data back from your server. This isn't a good idea since it limits the cancelabilty of your operation. NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop]; if ( currentRunLoop ) { // 1. Start the URLConnection! mURLConnection = [NSURLConnection connectionWithRequest:mURLRequest delegate:self]; [mURLConnection start]; // 2. We have a run Loop, so wait until the connection is finished while ( !done ![self isCancelled] ) { // Run the RunLoop! NSDate* dateLimit = [[NSDate date] addTimeInterval:0.1]; [currentRunLoop runUntilDate:dateLimit]; } // 3. Report your results to your main thread! … } This is polling and is generally a bad idea, also with such a low timeout your thread will thrash. Furthermore it ties the worker thread up until the operation is complete. You should instead make a 'concurrent' NSOperation subclass as it's described in NSOperation parlance. What it really means is an asynchronous one. Implement all the required 'concurrent operation' methods, and in -start you do as you were doing, create an NSURLConnection and schedule it in the +[NSRunLoop mainRunLoop]. In the completed callbacks (under error or success conditions) you mark the operation as isFinished. This makes your operation cancellable, and frees the worker thread up to service other work units. Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTextField sendActionOn:
Here's why I need this - I've been trying to solve this problem for 2 weeks! This issue all revolves around a NSCollectionView. Each CollectionViewItem has a view containing a NSTextField, NSDatePicker, NSButton (checkbox), and an NSLevelIndicator. The selection index of my CollectionView is binded to the selection index of an NSArrayController. The problem I having is if the user performs a mouseDown in the TextField I need to update the selectionIndex of the array controller so the CollectionView will show the appropriate view as selected. Without this, the wrong view is selected. Here's a quick example: 1) click the add button twice to create two items in my collectionView. Items with index 0 and 1. Since item 1 was the last one created, it is selected (I have it showing a grey box). 2) click your mouse into the text field of the item at index 0 and start typing The user would expect item 0 to be the selected item but it's not. The array controller still thinks item 1 is selected. It needs to be told otherwise. If the user pressed the remove button item 1 would be removed. This is why I want to fire an action when the user inserts into the text field (just like I do when the user clicks the checkbox). I want to change the selectedObject in the array controller. The problem I'm having with subclassing the NSTextField is I can't figure out how to get the CollectionViewItem from the subclassed TextField. If I could I could then execute my method to update the ArrayController. I tried creating an IBOutlet to the CollectionView, the ArrayController and the CollectionViewItem but they all come back as nil. I think I read here that IBOutlets don't work in this instance. I also tried setting up my own Notification but the CollectionViewItem never receives it (other objects do). This is tricky, any help you may have would be appreciated. Brad On Jan 17, 2010, at 6:12 AM, Graham Cox wrote: On 17/01/2010, at 3:56 PM, Brad Stone wrote: I was able to capture the mouseDown event in the field but only in a subclass which is causing me problems elsewhere. Indeed, a mouse click is not the only reason a field might become focused - the user could tab into it as well. Overriding -becomeFirstResponder should do it. Taking a step back though, WHY do you need to get notified here? What are you trying to do? There might be a better way. --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: Can a model key path binding access a super class property
Grant Christensen mailto:gran...@bigpond.net.au wrote (Sunday, January 17, 2010 6:53 AM +1000): In my window I have a NSTableView that is using an array controller to get access to my data. The array controller is bound to an array of BBSMoreSpecific classes. The problem I am having is that all of my columns bound to the fields in the BBSMoreSpecific class show their data, but those bound to those in the base class do not. I am using a simple model key path of just the name of the ivar, so aValue and anotherValue. Can the bindings access the base class or can they only access values in the class the array controller is directly connected to? Of course you can. This is a basic principle of object oriented languages (unless there's scoping, but Objective-C doesn't support that). You could verify this by using a key-value path to access any of the object's NSObject properties, like -description. I suspect that something else is wrong. Your simplistic example appears to be valid, but it's obviously not the code you're using. It time to hit the debugger Since you've declared these as formal properties, KVO should be accessing these properties via their accessor methods. One trick is to override the base-class getter method in your subclass like this: @implementation BBSMoreSpecific ... - (NSString*)aValue { NSString* value = [super aValue]; //NSLog(@%s returning '%@',__func__,value); return value; // -- set breakpoint here } Now you can set a breakpoint or log every access to that property. You shouldn't have any problem verifying if the correct messages are being sent (or not), by whom, and then work backwards from there. -- James Bucanek ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bindings Problem
On Sat, 2010/01/16, Ken Thomases k...@codeweavers.com wrote: On 2010 Jan 14, at 17:11, Carter R. Harrison wrote: My model is an NSMutableSet that contains NSMutableDictionaries. I think this is asking for trouble. A set of mutable dictionaries doesn't make much sense. ...Equal is determined by the -isEqual: and -hash methods, not by identity (memory location). So, it's quite possible that he has a hash used by the NSMutableSet which doesn't depend on the contents of the mutable dictionary once it's been created. Still, though I can imagine someone wanting such a set-up, I have to wonder what purpose it serves, as opposed, e.g., to a mutable dictionary of dictionaries, or a mutable array of dictionaries. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSTextField sendActionOn:
On 17 Jan 2010, at 16:30, Brad Stone wrote: Here's why I need this - I've been trying to solve this problem for 2 weeks! This issue all revolves around a NSCollectionView. Each CollectionViewItem has a view containing a NSTextField, NSDatePicker, NSButton (checkbox), and an NSLevelIndicator. The selection index of my CollectionView is binded to the selection index of an NSArrayController. The problem I having is if the user performs a mouseDown in the TextField I need to update the selectionIndex of the array controller so the CollectionView will show the appropriate view as selected. Without this, the wrong view is selected. Here's a quick example: 1) click the add button twice to create two items in my collectionView. Items with index 0 and 1. Since item 1 was the last one created, it is selected (I have it showing a grey box). 2) click your mouse into the text field of the item at index 0 and start typing The user would expect item 0 to be the selected item but it's not. The array controller still thinks item 1 is selected. It needs to be told otherwise. If the user pressed the remove button item 1 would be removed. This is why I want to fire an action when the user inserts into the text field (just like I do when the user clicks the checkbox). I want to change the selectedObject in the array controller. The problem I'm having with subclassing the NSTextField is I can't figure out how to get the CollectionViewItem from the subclassed TextField. Does -superview not do the trick? Sometimes when I need to activate views on mouse clicks I use the following approach. Subclass NSWindow and register the views I need click detection in with NSWindow - addClickView: In NSWindow -sendEvent: I check to see if we have a hit and dispatch a message on the view Might help you out. @interface MGSClickWindow : NSWindow { NSHashTable *_clickViews; } - (void)addClickView:(NSView *)aView; @end @implementation MGSClickWindow /* NSWindow designated initialiser */ - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation { if ((self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation])) { _clickViews = [NSHashTable hashTableWithWeakObjects]; } return self; } /* add a click view click view must be a sub view of the NSWindow contentView */ - (void)addClickView:(NSView *)aView { if ([aView isDescendantOf:[self contentView]] [aView respondsToSelector:@selector(subviewClicked:)]) { // _clickViews will maintain a weak ref to aView so we don't need // to remove it [_clickViews addObject:aView]; } } /* send event This action method dispatches mouse and keyboard events sent to the window by the NSApplication object. */ - (void)sendEvent:(NSEvent *)event { // look for mouse down if ([event type] == NSLeftMouseDown) { // look for deepest subview NSView *deepView = [[self contentView] hitTest:[event locationInWindow]]; if (deepView) { for (NSView *aClickView in [_clickViews allObjects]) { if ([deepView isDescendantOf:aClickView]) { [(id)aClickView subviewClicked:deepView]; break; } } } } [super sendEvent:event]; } @end If I could I could then execute my method to update the ArrayController. I tried creating an IBOutlet to the CollectionView, the ArrayController and the CollectionViewItem but they all come back as nil. I think I read here that IBOutlets don't work in this instance. I also tried setting up my own Notification but the CollectionViewItem never receives it (other objects do). This is tricky, any help you may have would be appreciated. Brad On Jan 17, 2010, at 6:12 AM, Graham Cox wrote: On 17/01/2010, at 3:56 PM, Brad Stone wrote: I was able to capture the mouseDown event in the field but only in a subclass which is causing me problems elsewhere. Indeed, a mouse click is not the only reason a field might become focused - the user could tab into it as well. Overriding -becomeFirstResponder should do it. Taking a step back though, WHY do you need to get notified here? What are you trying to do? There might be a better way. --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
Re: NSTextField sendActionOn:
I finally had a breakthrough! I'm not sure it's the best solution but it works and hopefully will be instructive for others trying to do the same thing connection views. There's a lot of steps (which is why I think it may not be the best) so I'll try to be as clear as possible. 1) when a user clicks their mouse in my subclasses NSTextField I send this action: BOOL theResult = [NSApp sendAction:@selector(notifyViewOfMouseDown) to:nil from:nil]; 2) my subclassed view has a method that executes when this action is sent: - (void)notifyViewOfMouseDown { NSDictionary *d = [NSDictionary dictionaryWithObject:self forKey:@view]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName:SRVIsSelectedChanged object:self userInfo:d]; } This allows me to package up the view and send it along in a notification. Packaging the view is **key** here because this is the view that needs to be selected. My subclassed NSCollectionView is registered as an observer of this notification. When it receives this notification I execute this code to update the array controller with a new selectedObject - (void)handleViewSelections:(NSNotification *)note { View *v = [[note userInfo] objectForKey:@view]; int limit = [[self content] count]; for (int i = 0; i limit; i++) { NSCollectionViewItem *item = [self itemAtIndex:i]; View *thisView = [item view]; if ([thisView isEqual:v]) { [item setSelected:YES]; //my subclassed NSCollectionViewItem knows how to set itself as selected and update the array controller } } } Boy, I'm glad I figured that out! I'm sure there are a lot more experienced programmers than me out there so if anyone can think of a way I can do this without so many steps I'd be glad to learn from them. Jonathan, thanks for your suggestion. My subclassed NSTextField didn't respond to superview. I wish it did, it would have saved me a step. To adapt your solution I'd need to register each newly created view in my NSCollectionView link that back to the NSCollectionViewItem that has the code to set itself as selected and to update the array controller. I had to delete your reply from this message to make it thru the listserve size limit.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSURLRequest and NSOperationQueue
Thanks for the responses! It hadn't occurred to me to spin the runloop myself. My main reason for using an NSOperationQueue for the connections was because the spawner of the connections was also the connection delegate, and it would've taken some interesting code dancing to handle the delegate callbacks of all the possible connections, the model objects they're attempting to create, etc in the same object. What I ended up doing was creating a new class, DDURLConnectionDelegate, that is init'd with the object spawning the connections. This object exists solely to encapsulate the delegate callbacks of the NSURLConnection, and then, when finished, reports back to the connection spawner with the results, and is destroyed by the runloop. Now I can freely spawn as many connections as I need, all on the main thread, and have them all handled on a single thread, without having to worry about which connection is supposed to be manipulating which object. Cheers, Dave On Jan 17, 2010, at 9:20 AM, Keith Duncan wrote: Solution 1 would be to have you do a synchronous NSURLConnection in your main method. This will show you everything is working in that thread and that you do indeed get data back from your server. This isn't a good idea since it limits the cancelabilty of your operation. NSRunLoop* currentRunLoop = [NSRunLoop currentRunLoop]; if ( currentRunLoop ) { // 1. Start the URLConnection! mURLConnection = [NSURLConnection connectionWithRequest:mURLRequest delegate:self]; [mURLConnection start]; // 2. We have a run Loop, so wait until the connection is finished while ( !done ![self isCancelled] ) { // Run the RunLoop! NSDate* dateLimit = [[NSDate date] addTimeInterval:0.1]; [currentRunLoop runUntilDate:dateLimit]; } // 3. Report your results to your main thread! … } This is polling and is generally a bad idea, also with such a low timeout your thread will thrash. Furthermore it ties the worker thread up until the operation is complete. You should instead make a 'concurrent' NSOperation subclass as it's described in NSOperation parlance. What it really means is an asynchronous one. Implement all the required 'concurrent operation' methods, and in -start you do as you were doing, create an NSURLConnection and schedule it in the +[NSRunLoop mainRunLoop]. In the completed callbacks (under error or success conditions) you mark the operation as isFinished. This makes your operation cancellable, and frees the worker thread up to service other work units. Keith 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: NSURLRequest and NSOperationQueue
The issue that Dave has run into is that when you call the asynchronous NSURLConnection call, NSURLConnection looks to see what thread you are calling it on, and it will only call your delegate back on that Thread (if it exists). If you exit your NSOperation main method, your thread is going to be cleaned up, and you will never get the delegate callbacks you want. Re-reading Dave's original email, I think what's probably happening to him is that he may be switching the runLoops of ht eNSURLConnection BEFORE it has actually started. Here's the comment from the documentation: You may call these methods after the connection has started. However, if the connection is scheduled on multiple threads or if you are not calling these methods from the thread where the connection is scheduled, there is a race between these methods and the delivery of delegate methods on the other threads. The caller must either be prepared for additional delegation messages on the other threads, or must halt the run loops on the other threads before calling these methods to guarantee that no further callbacks will occur. Scott ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Bindings: NSMutableArray - NSArrayController - NSPopUp
I am struggling with bindings. I have worked through the examples in the Hillegass book, but it seems that none of the examples using NSPopUp quite matches what I need. In my app, just before a view appears, it gets handed a list of games in an NSMutableArray. It makes the array available with -(NSMutableArray*)gameList. I want the NSPopUp to contain a list showing the value of -(NSString*)description for each item in the list. I thought I was supposed to do this by adding an NSArrayController to my .nib file, and then making the following bindings: Array Controller's Content Array = File's Owner.gameList NSPopUp's Content = Array Controller.arrangedObjects At runtime I get a totally empty popup. I can imagine two possibilities for why it doesn't work: a) I've got the bindings wrong b) The array controller can't handle the fact that the gameList pointer changes right before the view gets shown Can anyone help me get this working? --- Just in case it helps pre-answer any questions you may have, here are minimal descriptions of my classes: @interface GameScores { } -(NSString*)description; @end @interface GameViewController { NSMutableArray* gameList; } @property (retain) NSMutableArray* gameList; @end In the .nib file, NSArrayController tries to manage File's Owner.gameList, and the NSPopUp is supposed to display the NSArrayControler's arrangedObjects. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
RegexkitLite - Possible bug?
I've been working with RegexkitLite, and I'm wondering whether someone else who has RegexkitLite can reproduce this problem, or spot what I'm doing wrong: NSString *originalString = @IMUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIU; // Using the built-in range: option NSString *firstTry = [originalString stringByReplacingOccurrencesOfRegex:@M(.*) withString:@M$1$1 range:NSMakeRange(1,57)]; NSLog(@firstTry result: %@,firstTry); // Using substringWithRange: first NSString *cutOriginalString = [originalString substringWithRange:NSMakeRange(1, 57)]; NSString *secondTry = [cutOriginalString stringByReplacingOccurrencesOfRegex:@M(.*) withString:@M$1$1]; NSLog(@secondTry result: %@,secondTry); Output: firstTry result: (null) secondTry result: MUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIU I contend that the results of firstTry and secondTry should be the same. What am I missing? 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: problem in display of leopard app on snowleopard
On 18/01/2010, at 2:58 AM, cocoa learner wrote: Hi All, I have encountered a veered problem (or I am not able to understand). I have developed an App (using NSImageView, NSView, NSProgressIndicator etc.) using Base SDK Mac OS X 10.5. And it works fine on leopard. But when I run the App on Snow Leopard the App (User interface) looks more dull (or whitish where my enabled button also look like disabled) in color. Any idea how to over come this problem with out changing the Base SDK from 10.5 to 10.6. The default gamma changed (unfortunately, IMO) from 1.8 to 2.2 in Snow Leopard. I guess you'll just have to get used to it, like everyone else. --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: If Array Controller is empty, how to populate pop-up list?
Hi Ken, Thanks for your tips. We're closer I think. I took off the Selected Index binding and instead bound the Selected Value to ArrayController-selection-name. I'm probably binding it wrong though, because I haven't quite gotten it to work yet. I think what you say makes sense, about the selection objects and enabled properties. I have a string in all three bindings' No Selection Placeholder for the popup bindings (Content, Content Values, and Selected Value), but instead, when the array controller is empty, the popupbutton is both disabled and empty. Conditionally Sets Enabled is checked AND Avoid Empty Selection is checked, but, no dice... You said this is what worked for you? :/ Jenny With some experimentation, I discovered the following: I bound the pop-up's content to the array controller's arrangedObjects. I bound its Selected Value or Selected Object (but not Selected Index) to the array controller's selection with an appropriate model key path. For the content binding, I set a No Selection Placeholder string. Then, whenever the array controller had no selection, the pop-up showed the placeholder string. If the Selected Value binding's Conditionally Sets Enabled option is on (the default), then the pop-up is disabled when there's no selection in the array controller. This is sort of bad if the controlled array is not empty but the array controller has no selection. In that case, the pop-up shows the placeholder but is disabled, so the user can't access the other items in the pop-up. However, the array controller won't have no selection if its Avoid Empty Selection property is enabled (again, the default). With that property enabled, the pop-up shows the placeholder and is disabled only if there's nothing in the controlled array. If there are objects in the array, then the array controller has a selection and the pop-up shows it and is enabled. So, Conditionally Sets Enabled on the pop-up's Selected Value or Object binding, plus Avoids Empty Selection on the array controller works well. Turning both of those off makes for a functional but possibly strange interface; when the array is non-empty but the array controller has no selection, the pop-up shows the placeholder but is enabled and also contains the normal items. I hope that helps. Cheers, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[SOLVED]: Re: Can a model key path binding access a super class property
Thanks for the nudge in the right direction James... I went back to the debugger and found an underlying problem with the two variables in the base class that were not coming through. It as a mere coincidence that it was those two in the base class, and I was not setting them correctly in the first place. Always the simple answers :) regards, Grant On 18/01/2010, at 3:04 AM, James Bucanek wrote: Grant Christensen mailto:gran...@bigpond.net.au wrote (Sunday, January 17, 2010 6:53 AM +1000): In my window I have a NSTableView that is using an array controller to get access to my data. The array controller is bound to an array of BBSMoreSpecific classes. The problem I am having is that all of my columns bound to the fields in the BBSMoreSpecific class show their data, but those bound to those in the base class do not. I am using a simple model key path of just the name of the ivar, so aValue and anotherValue. Can the bindings access the base class or can they only access values in the class the array controller is directly connected to? Of course you can. This is a basic principle of object oriented languages (unless there's scoping, but Objective-C doesn't support that). You could verify this by using a key-value path to access any of the object's NSObject properties, like -description. I suspect that something else is wrong. Your simplistic example appears to be valid, but it's obviously not the code you're using. It time to hit the debugger Since you've declared these as formal properties, KVO should be accessing these properties via their accessor methods. One trick is to override the base-class getter method in your subclass like this: @implementation BBSMoreSpecific ... - (NSString*)aValue { NSString* value = [super aValue]; //NSLog(@%s returning '%@',__func__,value); return value; // -- set breakpoint here } Now you can set a breakpoint or log every access to that property. You shouldn't have any problem verifying if the correct messages are being sent (or not), by whom, and then work backwards from there. -- James Bucanek --- Grant Christensen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Bindings Problem
On Jan 17, 2010, at 11:15 AM, Jeffrey Oleander wrote: On Sat, 2010/01/16, Ken Thomases k...@codeweavers.com wrote: On 2010 Jan 14, at 17:11, Carter R. Harrison wrote: My model is an NSMutableSet that contains NSMutableDictionaries. I think this is asking for trouble. A set of mutable dictionaries doesn't make much sense. ...Equal is determined by the -isEqual: and -hash methods, not by identity (memory location). So, it's quite possible that he has a hash used by the NSMutableSet which doesn't depend on the contents of the mutable dictionary once it's been created. Huh? The hash in question is that of the mutable dictionaries. He doesn't get to decide this. It's a near certainty that the hash of a dictionary is sensitive to its contents. First, logically, how else would the NSDictionary implement equality? Second, the documentation I cited virtually asserted that it's so. So, if you mutate a dictionary while it's inside a collection, that will cause trouble. The documentation I cited says this, too, without equivocation. He also doesn't get to decide on the hash of the set, if that's what you were thinking about. He could implement some custom class and decide how its hash is implemented, but that's beside the point I was making. In fact, that was one of my suggested solutions. In other words, I'm not sure what you're trying to say. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: If Array Controller is empty, how to populate pop-up list?
On Jan 17, 2010, at 4:36 PM, Jenny M wrote: Thanks for your tips. We're closer I think. I took off the Selected Index binding and instead bound the Selected Value to ArrayController-selection-name. I'm probably binding it wrong though, because I haven't quite gotten it to work yet. I think what you say makes sense, about the selection objects and enabled properties. I have a string in all three bindings' No Selection Placeholder for the popup bindings (Content, Content Values, and Selected Value), but instead, when the array controller is empty, the popupbutton is both disabled and empty. Conditionally Sets Enabled is checked AND Avoid Empty Selection is checked, but, no dice... You said this is what worked for you? :/ Yes, that sounds like what I did. However, on thinking some more about this, I think I was on the wrong track. The selection value or object bindings of the pop-up would tend to set the bound-to property to whatever was selected in the pop-up. So, if you bind the selected value to ArrayController.selection.name, when the pop-up selection changes, it would attempt to set the name property of the object selected in the ArrayController. That's not what you want. Although the Selected Index of the pop-up may sensibly be bound to the array controller's selection index, which will properly result in the selection tracked by the array controller matching the selection in the pop-up, that doesn't appear to trigger the No Selection placeholder of the content bindings, as you've discovered. Basically, the array controller doesn't return the NSNoSelectionMarker marker for its selectionIndex property, it just returns NSNotFound. So, try this: make a property on your window controller, app controller, or other appropriate coordinating controller (not the array controller, which is a mediating controller; probably this would be the same controller which provides the content for the array controller). This new property will hold the state which the pop-up represents in the GUI. Bind either the pop-up's selected object or selected value, whichever makes most sense for your design, to this property. This property can be set when the array has contents, but when the array is empty it can return the NSNoSelectionMarker instead of, for example, nil. That should be sufficient to trigger both the No Selection Placeholder and the Conditionally Sets Enabled bindings, leaving the pop-up disabled and showing the placeholder. Alternatively, if the new property is bound to the pop-up's selection value, you can have it just directly return the placeholder when the array is empty. To disable the pop-up, you can bind its Enabled binding to arraycontroller.arrangedobjec...@count. Since the value of this new property changes depending on whether or not the array has contents, you'll want to tell KVO that it's dependent on the array property (+keyPathsForValuesAffectingKey). Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: RegexkitLite - Possible bug?
On Sun, Jan 17, 2010 at 4:15 PM, K.Darcy Otto do...@csusb.edu wrote: I've been working with RegexkitLite, and I'm wondering whether someone else who has RegexkitLite can reproduce this problem, or spot what I'm doing wrong: NSString *originalString = @IMUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIU; // Using the built-in range: option NSString *firstTry = [originalString stringByReplacingOccurrencesOfRegex:@M(.*) withString:@M$1$1 range:NSMakeRange(1,57)]; NSLog(@firstTry result: %@,firstTry); // Using substringWithRange: first NSString *cutOriginalString = [originalString substringWithRange:NSMakeRange(1, 57)]; NSString *secondTry = [cutOriginalString stringByReplacingOccurrencesOfRegex:@M(.*) withString:@M$1$1]; NSLog(@secondTry result: %@,secondTry); Output: firstTry result: (null) secondTry result: MUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIUUIUIUIU I contend that the results of firstTry and secondTry should be the same. What am I missing? Thanks. If something isn't working quite right, it's often a good idea to to get the NSError object if the API supports it. In this case: NSError *error = NULL; NSString *firstTry = [originalString stringByReplacingOccurrencesOfRegex:@M(.*) withString:@M$1$1 options:RKLNoOptions range:NSMakeRange(1,57) error:error]; NSLog(@firstTry result: %@,firstTry); NSLog(@error: %@, error); NSLog(@error: %@, [error userInfo]); 2010-01-17 19:04:40.513 list_bug[73048:a0f] firstTry result: (null) 2010-01-17 19:04:40.513 list_bug[73048:a0f] error: Error Domain=RKLICURegexErrorDomain Code=-124 UserInfo=0x409850 The ICU library returned an unexpected error code. 2010-01-17 19:04:40.514 list_bug[73048:a0f] error: { NSLocalizedDescription = The ICU library returned an unexpected error code.; NSLocalizedFailureReason = The error U_STRING_NOT_TERMINATED_WARNING occurred.; RKLICURegexErrorCode = -124; RKLICURegexErrorName = U_STRING_NOT_TERMINATED_WARNING; RKLICURegexRegex = M(.*); RKLICURegexRegexOptions = 0; } The ICU functions that perform the search and replace functionality have been a big source of bugs in RegexKitLite. The ICU functions have a particularly error prone and brittle calling syntax. Since you're performing a search and replace, the size of the replaced string can be quite a bit larger than the original string. Your example replacement string essentially doubles the size of the final, replaced string. RegexKitLite makes an educated guess at what the size of the final, replaced string is going to be. The ICU library fills up whatever buffer you happen to give it, but when it runs out of space, it returns an error code U_BUFFER_OVERFLOW_ERROR. Now, it's supposed to allow you to keep calling the append and replace string functions so it can tally up the exact size of the buffer that you would need to complete the replacement. Naturally, there's bugs in the replacement code in at least some versions of ICU where the first overflow error causes the append and replace functions to stop processing because There's an error!. The API says that you only ever need to do two passes of a search and replace at most: if the first pass had too small a buffer, you'll get the size of buffer you need, and therefore the second run is guaranteed to succeed because it has calculated the required sizes. So, RegexKitLite has workarounds to compensate for this broken behavior. To do this, RegexKitLite needs to detect the fact that a buffer over flow error has occurred, reset the error status so that ICU thinks it can keep going, and rinse and repeat until ICU says it's finished. However, this introduces another problem: Using this technique, you can really only return one error condition. And if you've got a buffer overflow condition, that's your error. If a second error pops up, then what? From past experience, these routines are pretty brittle, and trying to compensate for them usually just leads to more problems. Therefore, I've decided to take an extremely conservative approach and abort if things start to go sideways. While I'm sure something thought it was a great idea to warn you about your string is not terminated, in reality it does nothing but complicate things.. especially because it's no longer unambiguous if the U_STRING_NOT_TERMINATED_WARNING warning/error is masking an underlying U_BUFFER_OVERFLOW_ERROR because the buffer over flow error code is completely buggy. In this particular case, it looks like you happened to create a replacement string that is exactly the same size as the size RegexKitLite choose for its temporary buffer. A possible work around is to use the pre-4.0 version that's in SVN. It has support for the new Blocks syntax and you can use it to do a search and replace like so: NSString *replacedString = [originalString stringByReplacingOccurrencesOfRegex:@M(.*) options:RKLNoOptions
Screen saver using Asynchronous IO lags at close
I am writing a screen saver that forks a process and reads its stdout chunk by chunk. Since I didn't want it to block on reads, I tried to find the non-blocking IO parts of Cocoa. I found Cocoa's NSNotificationCenter, and the associated methods with the NSFileHandle class, and that seemed to fit the bill. It works fine *except* it doesn't notice the closes. My guess is it has something to do with the main loop being blocked after the close. It notices the last chunk of data and the close at the same time, but then it never notices after my last waitForDataInBackgroundAndNotify call. I don't want the routine reading the data to be blocked, but I want to know in a timely way if the file handle is closed. How do I do that? What should I be doing? Justin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Blocking for input during a loop?
Hi Is it possible, in Cocoa, do program a loop which goes something like this: for i=1 to 20 do something block for GUI user input do something with the input repeat It is for a simple game that plays tones etc, and lets the user guess what was played. Originally, I had implemented it without a loop, just using regular target/action mechanisms. The code got awfully complex with too many state variables, and it got difficult to implement new functionality etc. So, I tried implementing it as a loop running in a separate thread, but the loop is supposed to add/remove subviews on an NSView as the game progresses, and I found out that NSView doesn't want you to do that from a different thread than the main thread. I thought it would get cumbersome to arrange for messaging to the main thread to switch views, so I thought maybe running the loop in the main thread, and using NSRunLoop might be a solution? I have no clue about NSRunLoop, but I tried that idea, and implement the method waiting for UI input this way: -(int)waitForInput { while( inputAvailable != CodeInput ) [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; inputAvailable = NoInput; return( inputCode ); } The event handling methods should then update the instance variable inputAvailable to equal CodeInput (an enum value), and the inputCode would be updated to tell the game loop what choice the user made. But during the NSRunLoop statement no input is accepted at all. The handler methods are never run. I guess I'm completely lost and that NSRunLoop was never meant for this type of thing. The game has several windows in which the user can click to respond to the game questions, therefore trying to run modally for one window is not ideal. If running modal for a window is the recomended way, I might look into collecting all the current input views into one window. So, what do you recommend? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Crash on Snow Leopard in _LSAcquireIconRefForURL
I'm seeing an identical crash to this one reported in September 2009: http://lists.apple.com/archives/Cocoa-dev/2009/Sep/msg01781.html There's no resolution in that thread so I was wondering whether anyone had any ideas on how to circumvent this. I overrode _notePendingRecentDocumentURLsForKey: and that stops it from crashing but I'm not sure that's the best course of action. Thanks, Dusan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 Snow Leopard in _LSAcquireIconRefForURL
On Sun, Jan 17, 2010 at 6:47 PM, Dusan du...@dusanv.net wrote: I'm seeing an identical crash to this one reported in September 2009: If you can reliably reproduce the crash, test against the latest seed to which you have access. If it's still a problem, file a bug. I *think* I've seen this crash in the wild before, but I don't think I've seen anything in the 10.6.1 or 10.6.2 release notes about addressing it. Worth filing a bug report anyway. --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: Blocking for input during a loop?
On Sun, Jan 17, 2010 at 1:59 PM, Per Bull Holmen pbhol...@yahoo.com wrote: Is it possible, in Cocoa, do program a loop which goes something like this: for i=1 to 20 do something block for GUI user input do something with the input repeat This is a bad idea. Don't block the UI thread, because then the user will see a beachball. Sounds like you need to reread the Cocoa Event Handling Guide: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/Introduction/Introduction.html Your architectural difficulties also betray an unfamiliarity with MVC design. I suggest you read the Cocoa Design Patterns section of the Cocoa Fundamentals Guide, delve into the AppKit classes to see how that document relates to the actual framework, and then iterate your own design over and over (perhaps with pencil and paper for a while), keeping in mind the things you've learned from the documentation and from using the classes in AppKit. AppKit classes need to maintain a lot of state information, particularly when doing things like dragging or other input-driven processes. Here is the relevant document: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6 --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: Crash using IKImageBrowserView
Were these crashes under Leopard or Snow Leopard. I was seeing similar crashes in GLEngine under GC/Leopard but so far haven't been able to reproduce any of them under Snow Leopard. On Apr 9, 2009, at 10:32 AM, Bill Bumgarner wrote: On Apr 8, 2009, at 12:36 PM, Ashley Clark wrote: Thread 0 Crashed: 0 GLEngine0x1e4daf17 glDeleteTextures_Exec + 23 1 libGL.dylib 0x941cc476 glDeleteTextures + 38 2 com.apple.imageKit 0x93aa4684 _deleteTextureForIKGLImageInfo + 105 3 com.apple.imageKit 0x93aa46da _removeOwners + 53 4 com.apple.CoreFoundation0x942bcb29 CFDictionaryApplyFunction + 169 5 com.apple.imageKit 0x93aa528a -[IKGLSharedContextRegistry removeOwner:] + 141 6 com.apple.CoreFoundation0x9436ba3d __invoking___ + 29 Known bug. It has been fixed. If you (or anyone else) need more information about when the fix might be available, etc, please contact Apple's Developer Tech Support. Ashley On Dec 28, 2009, at 10:13 PM, Dan Treiman wrote: I'm seeing a recurring but intermittent crash in my GC-enabled app, which uses multiple IKImageBrowserViews. Has anybody seen anything like this? Have any insight as to why its crashing here? Stack: Thread 0 Crashed: 0 GLEngine 0x00011b051940 glGetError_Exec + 16 1 com.apple.imageKit0x000100cc81b4 -[IKTexturePacker releaseTexturePackerAtIndex:] + 309 2 com.apple.imageKit0x000100cd71e3 -[IKVRamManager _unbind:notifyDelegate:] + 471 3 com.apple.imageKit0x000100cd7d10 -[IKVRamManager removeEntriedOlderThanSessionID:] + 404 4 com.apple.imageKit0x000100cd23b5 -[IKCacheManager removeEntriedOlderThanSessionID:] + 47 5 com.apple.imageKit0x000100cd2ba1 -[IKCacheManager IKCleanTimedOutCache] + 174 6 com.apple.Foundation 0x7fff84081ca3 __NSFireDelayedPerform + 307 7 com.apple.CoreFoundation 0x7fff83f33245 CFRunLoopRunSpecific + 3797 8 com.apple.HIToolbox 0x7fff83b8bd0e RunCurrentEventLoopInMode + 278 9 com.apple.HIToolbox 0x7fff83b8bb44 ReceiveNextEventCommon + 322 10 com.apple.HIToolbox 0x7fff83b8b9ef BlockUntilNextEventMatchingListInMode + 79 11 com.apple.AppKit 0x7fff82ff2e70 _DPSNextEvent + 603 12 com.apple.AppKit 0x7fff82ff27b1 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 136 13 com.apple.AppKit 0x7fff82fec523 -[NSApplication run] + 434 14 com.apple.AppKit 0x7fff82fb92f0 NSApplicationMain + 373 15 com.gendaigames.GameSalad 0x00012290 start + 52 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
Typo in notification name
Hi all! I've been implementing a preferences for my app to be added to login item list and wanted to observe notification for changes in loginItems list. I used notification watcher app and noticed that apple has a typo in notification name: - com.apple.loginItemsListDidChnage instead of - com.apple.loginItemsListDidChange This typo seems to be dating since 2006 (according to this thread: http://www.osxentwicklerforum.de/thread.php?postid=39885). Was apple notified about this? -- Sweet bits of Cocoa programming http://cocoakids.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