Handling mouse events on transparent window conditionally
Hi, I am developing an Desktop application in which I should be able to take mouse events on transparent window. But, transparent NSWindow does not take mouse events. So, I have set setIgnoreMouseEvents to NO which allows the transparent window to take mouse events. I have the problem in the following scenario: There is dynamically created rectangular shape on this window. The transparent window should not take mouse events in this region; it should be delegated to the window (of some other app) that is present behind this shape. For this purpose, if the mouseDown event is inside the shape I am setting setIgnoreMouseEvents to YES. Now, if the user performs mouse events in the area outside the shape the transparent window should take the event. Since, setIgnoreMouseEvents is set to YES, window does not take mouse events. There is no way to identify that mouseDown event has occurred so that I can set setIgnoreMouseEvents to NO. Could someone suggest me some best method to handle mouse events on transparent window? Thanks and Regards, Deepa--- Robosoft Technologies - Come home to Technology Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 on transparent window conditionally
On May 31, 2011, at 1:33 AM, Deepa wrote: I am developing an Desktop application in which I should be able to take mouse events on transparent window. But, transparent NSWindow does not take mouse events. So, I have set setIgnoreMouseEvents to NO which allows the transparent window to take mouse events. I have the problem in the following scenario: There is dynamically created rectangular shape on this window. The transparent window should not take mouse events in this region; it should be delegated to the window (of some other app) that is present behind this shape. For this purpose, if the mouseDown event is inside the shape I am setting setIgnoreMouseEvents to YES. Now, if the user performs mouse events in the area outside the shape the transparent window should take the event. Since, setIgnoreMouseEvents is set to YES, window does not take mouse events. There is no way to identify that mouseDown event has occurred so that I can set setIgnoreMouseEvents to NO. Could someone suggest me some best method to handle mouse events on transparent window? The Mac OS X Window Server has to decide where to route events. It is a process outside of any particular application. Once it has picked which window (and therefore application) will receive an event, that's the end of the matter. That application chooses how to respond (including, possibly, doing nothing), but the event won't be delivered to any other application. You can't dynamically choose to pass an event along to the next application. (You could try to approach this using CGEventTaps, but I doubt you'd achieve anything satisfactory.) The better approach is to use multiple transparent overlay windows. If you need to make a frame that accepts mouse events around a rectangular area that does not, you may need four transparent windows for the frame and, if necessary, one for the interior rectangle. You can use child windows (-[NSWindow addChildWindow:ordered:]) to make sure the windows move together. 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: Why does NSArray count return NSUInteger?
On 31 May 2011, at 10:00, Alejandro Rodríguez wrote: Hey Julius, The reason for using NSUInteger on such a high level framework as Cocoa may not seem relevant but for the sake of completeness let me go down a road less explored by many of the other answers. I think using NSUInteger vs NSInteger is the result of a leaky abstraction. It's more than likely that it has to do with the underlying implementation of NSArray which is surely based on C arrays. If we go back to simpler times the use of Unsigned datatypes becomes really obvious. For example… C was introduced in 1969 when only 8 bit processors existed (16-bit processors were introduced in 1976) which means that using a unsigned index could let you work with an array of 256 (0-255) elements vs 128 (0-127). That alone justifies the decision completely. Let's explore the low level details a little more. Specifying the index of an Array is really specifying an offset from a given pointer, if for example you have a C Array in the stack then specifying a negative index will modify previous data in your code which could lead to data loss (or even infinite loops on some nicely engineered examples). However because of the nature of the stack modifying some pointer further down (unsigned) has a less ill effects (other than the well known buffer overflow security holes). When designing APIs the designer takes the possibility of error into account and it's usually preferred to expose errors that will cause the app to crash and burn in flames instead of subtly corrupting data or getting into some weird state that only crashes once every 6 months. For example: arr[(NSInteger)(0 - 2)] will corrupt data and it's likely that it won't crash. arr[(NSUInteger)(0 - 2)] will probably always crash. Finally there is the point of scope. Objective-C started being designed and used before 32-bit personal computers gained any traction so using unsigned values made a huge difference. This is much much earlier that Cocoa but NSArray is not part of the Cocoa framework but part of the Foundation Framework which has a much broader spectrum. NSArray is toll-free bridged with CFArray which being part of CoreFoundation is made to work cross-platform and thus should try to be as generic as possible. It may be hard to understand but in cases like these using the unsigned version is more flexible because it is less wasteful. Using the type that best represents the data is important here because using a signed integer to represent something that can only nonnegative would in fact be wasting half of the space. Designing API is very tricky because many things once introduced are set in stone (changing the interface would break existing applications) and many things, including the programmer's bad memory, are taken into account. Hope this helps. Regards, - Alej Thanks. Exactly what I was looking for. Julius http://juliuspaintings.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Application Design
Thanks for all your answers, they make complete sense. I have one more related question. I have developed a custom, stateful WebServiceInterface object, which manages all connection requests made to an XML-RPC server. Being stateful, I initialise this object when the app launches and at the moment I store a pointer to it in a header file, which I include in all view controllers. This allows me to make a request for data from anywhere. In a similar way, I feel that storing a global pointer is not best practise and can't help but think there is a more elegant way of doing this. One option I have considered if storing/initialising the object in the app delegate and then creating a utility method in the delegate that wraps the object call. Is this the best solution or is there a design pattern I am unaware of? Many thanks! On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote: On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote: Thanks for your response Steve. I have considered using the nsnotification service but what if you need to not only let another object know when an event has occurred but you also need to send that object some data? For example a user selects an option in a table - the selection must be conveyed in some way to the vc I'm pushing on the nav controller stack so that it's view is dynamic depending on the selection. As far as I'm aware that is not possible using notifications. That's very doable with notifications. See the object and userInfo methods in NSNotification and corresponding methods in NSNotificationCenter. In general I create a new vc/nib for *every* screen I have in the app. Let's take a navigation app as an example. Are you saying that the hierarchy should be: - 'root view controller' (has overall control, contains navigation logic and sends data between the containing view controllers) -- 'nav controller' -- 'all view controllers to be pushed/popped' ...where the nav controller and its view controllers are stored and initialised inside the 'root view controller'? Well, I'd say the view controllers aren't stored inside the root view controller; they are pushed onto the navigation stack as and when needed. Unless you are doing some caching, I wouldn't store the view controllers outside the navigation stack. (If you do implement caching, make sure you respond to memory warnings by flushing the cache!) In a navigation based application I feel that your architecture is simplified by design. Since only one view controller (notwithstanding modal view controllers) is on screen at any time, and they are all arranged hierarchically, parents should configure their children before pushing them onto the stack. When children need to communicate back to their parents (for example, if you push an editor view controller from a summary view controller, which needs to be updated when the editor view controller makes changes), you can use KVO or notifications, but if the communication is by design of interest only to the parent and child view controllers, just make the parent the delegate of the child. So if the child, say, had a list of favorite URLs for the user to select, it could call something like [delegate didSelectFavorite:url] which would cause the parent to be updated (and change appearance when the child is popped off the stack). (Sent from my iPad.) -- Conrad Shultz www.synthetiqsolutions.com -- Director, Bias Development Ltd. *e* d...@biasdevelopment.com *m* +44 (0) 7748 544356 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Why does NSArray count return NSUInteger?
On 31/05/2011, at 7:36 PM, julius wrote: On 31 May 2011, at 10:00, Alejandro Rodríguez wrote: It's more than likely that it has to do with the underlying implementation of NSArray which is surely based on C arrays. NSArray is toll-free bridged with CFArray which being part of CoreFoundation is made to work cross-platform and thus should try to be as generic as possible. Problem is, the first statement I've quoted isn't the case, and the second, while true, is based on CFIndex, not NSUInteger, which is a typedef for signed long. (You can look at the source for CFArray in the Darwin sources: http://www.opensource.apple.com/source/CF/CF-476.15/CFArray.c ). However I think the historical perspective is helpful - the general principle is to always give yourself the maximum expansion room you can. Note that in the classic Mac OS many data structures were based on shorts, and in quite a few cases later APIs changed these from signed to unsigned to extend the useful capacity of a given structure. These days, the ubiquity of 32 and 64 bits hides the benefit that careful choice of types can give you, which was true until quite recently. --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
Stalling until notification is received
Hi all, I need to create a simple command line application that will stall (as in keep running without exiting) until it receives a certain distributed notification via NSDistributedNotificationCenter. What would be the best way to go about doing this? I assume I'd have to have a separate thread for observing the notification and then have some sort of loop running in main() that checks whether the notification has been received, but I'm not certain. Any tips would be appreciated. Thanks, Indragie___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Stalling until notification is received
On May 31, 2011, at 9:03 AM, Indragie Karunaratne wrote: I need to create a simple command line application that will stall (as in keep running without exiting) until it receives a certain distributed notification via NSDistributedNotificationCenter. What would be the best way to go about doing this? I assume I'd have to have a separate thread for observing the notification and then have some sort of loop running in main() that checks whether the notification has been received, but I'm not certain. Any tips would be appreciated. Distributed notifications are received via a run loop source. So, you have to run the run loop in order for them to be received. Furthermore, the distributed notification center's run loop source is only registered into one run loop, the first to obtain it. Because the frameworks use distributed notifications themselves, this is pretty much required to be the main thread's run loop, even if you wanted to try to register it elsewhere. (They'd probably beat you to it, anyway.) So, just run the run loop in the main thread repeatedly. In your notification-handling method, set a flag that it was received. In your loop that keeps running the run loop, exit if that flag is set. 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: How can I work with code completion in Xcode 4?
On Tue, May 31, 2011 at 8:00 AM, Guillermo Moral guillermo.mo...@leapfactor.com wrote: How can I work with code completion in Xcode 4 when I create a new project using a Template and have a static library. This is a tools question; it is more appropriate for the xcode-users list. --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: Autoreleased Data In Cocoa
Dear Nick and all, Thanks so much for your reply! I am still a new Cocoa developer so that I need to improve during the programming procedure. Now I modify the code and it works fine. The code is as follows. But I still have a question. If the autoreleased data will keep alive until the pool is drained, what if the data is autoreleased in a Cocoa auto-created pool? It will keep alive unless the process is shutdown? Thanks! Bing - (NSString *) receiveMessage { NSMutableString *receivedString; NSString *message; [isConnectedLock lock]; @try { if (isConnected) { char buffer[Constants.WWW.BUFFER_SIZE]; ssize_t numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { return Constants.WWW.NO_RECEIVED_MESSAGE; } buffer[numBytesReceived] = '\0'; receivedString = [[NSMutableString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEncoding]; NSRange range = [receivedString rangeOfString:Constants.WWW.DELIMITER]; if (range.location 0 range.location [receivedString length]) { message = [receivedString substringToIndex:range.location]; return message; } else { while (numBytesReceived 0) { NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init]; numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { [loopPool drain]; break; } buffer[numBytesReceived] = '\0'; NSString *newReceivedString = [[[NSString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEn coding] autorelease]; [receivedString appendString:newReceivedString]; range = [receivedString rangeOfString:Constants.WWW.DELIMITER]; if (range.location 0 range.location [receivedString length]) { message = [receivedString substringToIndex:range.location]; [loopPool drain]; break; } [loopPool drain]; } } return message; } else { return Constants.WWW.NO_RECEIVED_MESSAGE; } } @catch (NSException *e) { NSLog(@%@, e); return Constants.WWW.NO_RECEIVED_MESSAGE; } @finally { [isConnectedLock unlock]; [receivedString autorelease]; } } On Tue, May 31, 2011 at 11:13 AM, Nick Zitzmann n...@chronosnet.com wrote: On May 30, 2011, at 8:15 PM, Bing Li wrote: - (NSString *) receiveMessage { NSMutableString *receivedString; NSString *message; NSString *newReceivedString; [isConnectedLock lock]; @try { if (isConnected) { char buffer[Constants.WWW.BUFFER_SIZE]; // Receive remote data ssize_t numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { return Constants.WWW.NO_RECEIVED_MESSAGE; } buffer[numBytesReceived] = '\0'; // Convert data to NSString locally receivedString = [[NSMutableString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEncoding]; message = [[NSString alloc] initWithString:Constants.WWW.EMPTY_STRING]; Why are you storing a non-autoreleased object to a pointer and then writing over it later? // Since the data has specific formats, some simple
Re: Autoreleased Data In Cocoa
On May 31, 2011, at 9:32 AM, Bing Li wrote: But I still have a question. If the autoreleased data will keep alive until the pool is drained, what if the data is autoreleased in a Cocoa auto-created pool? It will keep alive unless the process is shutdown? No. The framework makes and drains pools as your application goes about its business. Just stick to the rules and don't worry about pools that are outside of your control. Thanks! Bing - (NSString *) receiveMessage { NSMutableString *receivedString; I would recommend initializing this to nil. Although it's highly unlikely, if a C++ or ObjC exception is thrown prior to receivedString being set, then your @finally method is going to crash sending an autorelease message to an uninitialized pointer. 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: Autoreleased Data In Cocoa
The Cocoa-created autorelease pool is automatically drained at an unspecified time, typically every few iterations of the run loops. You can trust it to do the right thing. -Matt Sent from my iPhone On May 31, 2011, at 8:32 AM, Bing Li lbl...@gmail.com wrote: Dear Nick and all, Thanks so much for your reply! I am still a new Cocoa developer so that I need to improve during the programming procedure. Now I modify the code and it works fine. The code is as follows. But I still have a question. If the autoreleased data will keep alive until the pool is drained, what if the data is autoreleased in a Cocoa auto-created pool? It will keep alive unless the process is shutdown? Thanks! Bing - (NSString *) receiveMessage { NSMutableString *receivedString; NSString *message; [isConnectedLock lock]; @try { if (isConnected) { char buffer[Constants.WWW.BUFFER_SIZE]; ssize_t numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { return Constants.WWW.NO_RECEIVED_MESSAGE; } buffer[numBytesReceived] = '\0'; receivedString = [[NSMutableString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEncoding]; NSRange range = [receivedString rangeOfString:Constants.WWW.DELIMITER]; if (range.location 0 range.location [receivedString length]) { message = [receivedString substringToIndex:range.location]; return message; } else { while (numBytesReceived 0) { NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init]; numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { [loopPool drain]; break; } buffer[numBytesReceived] = '\0'; NSString *newReceivedString = [[[NSString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEn coding] autorelease]; [receivedString appendString:newReceivedString]; range = [receivedString rangeOfString:Constants.WWW.DELIMITER]; if (range.location 0 range.location [receivedString length]) { message = [receivedString substringToIndex:range.location]; [loopPool drain]; break; } [loopPool drain]; } } return message; } else { return Constants.WWW.NO_RECEIVED_MESSAGE; } } @catch (NSException *e) { NSLog(@%@, e); return Constants.WWW.NO_RECEIVED_MESSAGE; } @finally { [isConnectedLock unlock]; [receivedString autorelease]; } } On Tue, May 31, 2011 at 11:13 AM, Nick Zitzmann n...@chronosnet.com wrote: On May 30, 2011, at 8:15 PM, Bing Li wrote: - (NSString *) receiveMessage { NSMutableString *receivedString; NSString *message; NSString *newReceivedString; [isConnectedLock lock]; @try { if (isConnected) { char buffer[Constants.WWW.BUFFER_SIZE]; // Receive remote data ssize_t numBytesReceived = recv(destinationSocket, buffer, Constants.WWW.BUFFER_SIZE, 0); if (numBytesReceived = 0) { return Constants.WWW.NO_RECEIVED_MESSAGE; } buffer[numBytesReceived] = '\0'; // Convert data to NSString locally receivedString = [[NSMutableString alloc] initWithBytes:buffer length:numBytesReceived encoding:NSUTF8StringEncoding];
Fuzzy string matching
Wondering if anyone knows of or has an Obj-C Class that can provide levels of fuzzy string matching... looking for % match or something similar. I have something now but it's returning results that aren't nearly accurate enough for me to employ with confidence. Thank you, Eric Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.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: Fuzzy string matching
I've used this in the past with pretty good results: http://weblog.wanderingmango.com/?pg=2 HTH, Dave Sent from my iPad On May 31, 2011, at 9:32 AM, Eric E. Dolecki edole...@gmail.com wrote: Wondering if anyone knows of or has an Obj-C Class that can provide levels of fuzzy string matching... looking for % match or something similar. I have something now but it's returning results that aren't nearly accurate enough for me to employ with confidence. Thank you, Eric Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.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/davedelong%40me.com This email sent to davedel...@me.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: Fuzzy string matching
Thanks - I'm not sure that's going to be flexible enough for me or not, but I'll give it a go. Thanks again! Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.net On Tue, May 31, 2011 at 12:47 PM, Dave DeLong davedel...@me.com wrote: I've used this in the past with pretty good results: http://weblog.wanderingmango.com/?pg=2 HTH, Dave Sent from my iPad On May 31, 2011, at 9:32 AM, Eric E. Dolecki edole...@gmail.com wrote: Wondering if anyone knows of or has an Obj-C Class that can provide levels of fuzzy string matching... looking for % match or something similar. I have something now but it's returning results that aren't nearly accurate enough for me to employ with confidence. Thank you, Eric Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.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/davedelong%40me.com This email sent to davedel...@me.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: Cocoa-preferred licensing key style?
Thanks everyone! This has definitely helped. Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Application Design
How about providing a singleton class method? Then you just include WebServiceInterface.h where needed. No need to have a global variable. @implementation WebServiceInterface ... + (WebServiceInterface*) sharedInterface { static WebServiceInterface* sharedInstance = nil; if (sharedInstance == nil) sharedInstance = [[WebServiceInterface alloc] init]; return sharedInstance; } ... @end foo = [[WebServiceInterface sharedInterface] someMethod]; On May 31, 2011, at 3:25 AM, Dan Hopwood wrote: Thanks for all your answers, they make complete sense. I have one more related question. I have developed a custom, stateful WebServiceInterface object, which manages all connection requests made to an XML-RPC server. Being stateful, I initialise this object when the app launches and at the moment I store a pointer to it in a header file, which I include in all view controllers. This allows me to make a request for data from anywhere. In a similar way, I feel that storing a global pointer is not best practise and can't help but think there is a more elegant way of doing this. One option I have considered if storing/initialising the object in the app delegate and then creating a utility method in the delegate that wraps the object call. Is this the best solution or is there a design pattern I am unaware of? Many thanks! On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote: On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote: Thanks for your response Steve. I have considered using the nsnotification service but what if you need to not only let another object know when an event has occurred but you also need to send that object some data? For example a user selects an option in a table - the selection must be conveyed in some way to the vc I'm pushing on the nav controller stack so that it's view is dynamic depending on the selection. As far as I'm aware that is not possible using notifications. That's very doable with notifications. See the object and userInfo methods in NSNotification and corresponding methods in NSNotificationCenter. In general I create a new vc/nib for *every* screen I have in the app. Let's take a navigation app as an example. Are you saying that the hierarchy should be: - 'root view controller' (has overall control, contains navigation logic and sends data between the containing view controllers) -- 'nav controller' -- 'all view controllers to be pushed/popped' ...where the nav controller and its view controllers are stored and initialised inside the 'root view controller'? Well, I'd say the view controllers aren't stored inside the root view controller; they are pushed onto the navigation stack as and when needed. Unless you are doing some caching, I wouldn't store the view controllers outside the navigation stack. (If you do implement caching, make sure you respond to memory warnings by flushing the cache!) In a navigation based application I feel that your architecture is simplified by design. Since only one view controller (notwithstanding modal view controllers) is on screen at any time, and they are all arranged hierarchically, parents should configure their children before pushing them onto the stack. When children need to communicate back to their parents (for example, if you push an editor view controller from a summary view controller, which needs to be updated when the editor view controller makes changes), you can use KVO or notifications, but if the communication is by design of interest only to the parent and child view controllers, just make the parent the delegate of the child. So if the child, say, had a list of favorite URLs for the user to select, it could call something like [delegate didSelectFavorite:url] which would cause the parent to be updated (and change appearance when the child is popped off the stack). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: Fuzzy string matching
CLucene might be a bit heavy, but it works great for me. -Heath From my iTouch4 On May 31, 2011, at 12:02 PM, Eric E. Dolecki edole...@gmail.com wrote: Thanks - I'm not sure that's going to be flexible enough for me or not, but I'll give it a go. Thanks again! Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.net On Tue, May 31, 2011 at 12:47 PM, Dave DeLong davedel...@me.com wrote: I've used this in the past with pretty good results: http://weblog.wanderingmango.com/?pg=2 HTH, Dave Sent from my iPad On May 31, 2011, at 9:32 AM, Eric E. Dolecki edole...@gmail.com wrote: Wondering if anyone knows of or has an Obj-C Class that can provide levels of fuzzy string matching... looking for % match or something similar. I have something now but it's returning results that aren't nearly accurate enough for me to employ with confidence. Thank you, Eric Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki http://blog.ericd.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/davedelong%40me.com This email sent to davedel...@me.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/heath.borders%40gmail.com This email sent to heath.bord...@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
How to set keyboard type for custom view?
Hi All, I have a view that accepts input using UIKeyInput. The VC's viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows the alphanumeric keyboard. I get input as expected through insertText: and deleteBackwards:. How does one change the keyboard type to UIKeyboardTypeNumberPad? I've tried conforming to UITextInputTraits in my custom view, but the keyboard does not appear to reach back to my view for the trait. Is there anything special when a protocol only includes properties? Or perhaps I have missed another [important] detail? Jeff ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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 set keyboard type for custom view?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 5/31/11 12:23 PM, Jeffrey Walton wrote: Hi All, I have a view that accepts input using UIKeyInput. The VC's viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows the alphanumeric keyboard. I get input as expected through insertText: and deleteBackwards:. How does one change the keyboard type to UIKeyboardTypeNumberPad? I've tried conforming to UITextInputTraits in my custom view, but the keyboard does not appear to reach back to my view for the trait. Is there anything special when a protocol only includes properties? Or perhaps I have missed another [important] detail? Can you show code? I ask because I just implemented a minimal example that I believe does what you are asking, with nothing fancy. I did not implement the backing store for UIKeyInput, but I don't see that that should matter here. In a UIView subclass (declared with UITextInputTraits, UIKeyInput) I implemented: - - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self becomeFirstResponder]; } - - (BOOL)canBecomeFirstResponder { return YES; } #pragma mark UIKeyInput methods - - (void)deleteBackward { } - - (void)insertText:(NSString *)text { } - - (BOOL)hasText { return NO; } #pragma mark UITextInputTraits methods - - (UIKeyboardType) keyboardType { return UIKeyboardTypeNumberPad; } And, as expected, when I tapped the UIView (in simulator), the numeric keypad appeared. This sounds like what you did, though...? The only thing I could think of is that your view controller is interfering, but the view comes before its controller in the responder chain, so it's not clear how this would happen (barring some very unorthodox implementation). - -- Conrad Shultz Synthetiq Solutions www.synthetiqsolutions.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFN5UY3aOlrz5+0JdURAjCKAJ4okqU/1NYWelDbWvXJ+/Qk5cFR+gCfZmzt A2LxTk3sa3kuVVVXpYa1k8Y= =ONTG -END PGP 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: How to set keyboard type for custom view?
On Tue, May 31, 2011 at 3:49 PM, Conrad Shultz con...@synthetiqsolutions.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 5/31/11 12:23 PM, Jeffrey Walton wrote: Hi All, I have a view that accepts input using UIKeyInput. The VC's viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows the alphanumeric keyboard. I get input as expected through insertText: and deleteBackwards:. How does one change the keyboard type to UIKeyboardTypeNumberPad? I've tried conforming to UITextInputTraits in my custom view, but the keyboard does not appear to reach back to my view for the trait. Is there anything special when a protocol only includes properties? Or perhaps I have missed another [important] detail? Can you show code? I ask because I just implemented a minimal example that I believe does what you are asking, with nothing fancy. I did not implement the backing store for UIKeyInput, but I don't see that that should matter here. In a UIView subclass (declared with UITextInputTraits, UIKeyInput) I implemented: [SNIP] And, as expected, when I tapped the UIView (in simulator), the numeric keypad appeared. This sounds like what you did, though...? The only thing I could think of is that your view controller is interfering, but the view comes before its controller in the responder chain, so it's not clear how this would happen (barring some very unorthodox implementation). Thanks Conrad. We had essentially the same code. `rm -rf build/` fixed it. Jeff ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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
iOS: getting the shakes
In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3). Is there something else I need to do to specifically enable delivery of shake events? I have scoured the docs but didn't find anything relevant. --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: iOS: getting the shakes
On May 31, 2011, at 9:35 PM, Graham Cox wrote: In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3). Is there something else I need to do to specifically enable delivery of shake events? I have scoured the docs but didn't find anything relevant. --Graham Well, how hard did you shake your computer? You have to actually shake the computer, as neither your mouse nor your keyboard have a motion sensor. Eli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iOS: getting the shakes
It's an iOS device, not a computer. No mouse, no keyboard. I think you want, - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event You make a subclass of UIView, instantiate it, and implement the above within that subclass. David On May 31, 2011, at 8:42 PM, Eli Bach wrote: On May 31, 2011, at 9:35 PM, Graham Cox wrote: In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3). Is there something else I need to do to specifically enable delivery of shake events? I have scoured the docs but didn't find anything relevant. --Graham Well, how hard did you shake your computer? You have to actually shake the computer, as neither your mouse nor your keyboard have a motion sensor. Eli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rowlandd%40sbcglobal.net This email sent to rowla...@sbcglobal.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: iOS: getting the shakes
On 01/06/2011, at 1:42 PM, Eli Bach wrote: Well, how hard did you shake your computer? You have to actually shake the computer, as neither your mouse nor your keyboard have a motion sensor. Eli You're a funny guy. :) I assume you are being funny: the simulator has a shake menu command to simulate the shake event. I'm sure you know that, but just in case... --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
NSOpenPanel not honoring some settings
Hello, I'm trying to display an NSOpenPanel that only allows to select plist files. I have the following code in place: NSOpenPanel *openPanel= [NSOpenPanel openPanel]; [openPanel setResolvesAliases:YES]; [openPanel setCanChooseDirectories:NO]; [openPanel setAllowsMultipleSelection:NO]; [openPanel setCanChooseFiles:YES]; [openPanel setPrompt:@Open]; [openPanel setAllowedFileTypes:[NSArray arrayWithObject:@plist]]; [openPanel beginSheetForDirectory:NSHomeDirectory() file:nil modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndImportSheet:returnCode:contextInfo:) contextInfo:NULL]; The documentation about setAllowedFileTypes states that The file type can be a common file extension, or a UTI... so I have no idea why the plist extension is not being honored. To make things more interesting, I can select directories (even though I have set setCanChooseDirectories with NO). Any idea why it's not working? What am I missing? Thanks! -- Tito ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iOS: getting the shakes
That should be a subclass of UIResponder. You don't need a UIView, but I suppose you could use an existing one. D On May 31, 2011, at 8:55 PM, David Rowland wrote: It's an iOS device, not a computer. No mouse, no keyboard. I think you want, - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event You make a subclass of UIView, instantiate it, and implement the above within that subclass. David On May 31, 2011, at 8:42 PM, Eli Bach wrote: On May 31, 2011, at 9:35 PM, Graham Cox wrote: In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3). Is there something else I need to do to specifically enable delivery of shake events? I have scoured the docs but didn't find anything relevant. --Graham Well, how hard did you shake your computer? You have to actually shake the computer, as neither your mouse nor your keyboard have a motion sensor. Eli ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rowlandd%40sbcglobal.net This email sent to rowla...@sbcglobal.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/rowlandd%40sbcglobal.net This email sent to rowla...@sbcglobal.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: iOS: getting the shakes
On 01/06/2011, at 1:55 PM, David Rowland wrote: I think you want, - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event You make a subclass of UIView, instantiate it, and implement the above within that subclass. Hmm, thanks but it's still not called. I have a subclass of UIView, and also a subclass of UIViewController. The controller is part of the responder chain after the view, so it *should* be called whether the view or the controller implements the method. Other events such as touches are passed along as expected, which is why I wondered if there's something else needed to enable shake events (e.g. a specific key in the info.plist). --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: iOS: getting the shakes
Is your uiresponder the first responder? On Jun 1, 2011, at 11:35, Graham Cox graham@bigpond.com wrote: In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3). Is there something else I need to do to specifically enable delivery of shake events? I have scoured the docs but didn't find anything relevant. --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/rols%40rols.org This email sent to r...@rols.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: NSOpenPanel not honoring some settings
On May 31, 2011, at 21:00, Tito Ciuro wrote: [openPanel setAllowedFileTypes:[NSArray arrayWithObject:@plist]]; [openPanel beginSheetForDirectory:NSHomeDirectory() file:nil modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndImportSheet:returnCode:contextInfo:) contextInfo:NULL]; You're using the wrong methods for NSOpenPanel. These methods are for NSSavePanel, prior to 10.6. For 10.5 compatibility, use the deprecated 'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:' method and specify the file type array as a parameter. Or for 10.6 only, use 'beginSheetModalForWindow:completionHandler:' in combination with 'setAllowedFileTypes:'. Also see here: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html under the 'setAllowedFileTypes:' method description, for a note about NSOpenPanel. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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: iOS: getting the shakes
On 01/06/2011, at 2:19 PM, Roland King wrote: s your uiresponder the first responder? Aha! No, it wasn't :) Thanks - it's working now. --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: NSOpenPanel not honoring some settings
Hi Quincey, On May 31, 2011, at 9:35 PM, Quincey Morris wrote: On May 31, 2011, at 21:00, Tito Ciuro wrote: [openPanel setAllowedFileTypes:[NSArray arrayWithObject:@plist]]; [openPanel beginSheetForDirectory:NSHomeDirectory() file:nil modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndImportSheet:returnCode:contextInfo:) contextInfo:NULL]; You're using the wrong methods for NSOpenPanel. These methods are for NSSavePanel, prior to 10.6. For 10.5 compatibility, use the deprecated 'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:' method and specify the file type array as a parameter. Or for 10.6 only, use 'beginSheetModalForWindow:completionHandler:' in combination with 'setAllowedFileTypes:'. Also see here: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/Reference/Reference.html under the 'setAllowedFileTypes:' method description, for a note about NSOpenPanel. I don't know how I missed this... I wish Xcode 4 had warned me that 'beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:' has been deprecated in 10.6. That would have saved some trouble! Thanks a lot for the help, -- Tito ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)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