NSTextView with irregular shape
Hello All! I need to implement NSTextView descendant similar to one used in Mac iMessages App. I have implemented live resizing, but how to set resizable image as its custom shape? 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Preventing the dictionary popup from appearing
Some parts of the UI of an application I'm working on are WebViews. When the mouse is over html/text displayed in these web views the user can display the inline word / dictionary popup by pressing command-control-d (or by using a 3 finger gesture). Is there a way to prevent the dictionary popup in WebViews? - None of the WebView delegates seem applicable (selection, drag and drop, and contextual menus are already disabled). - There is API to trigger the dictionary and I can detect when the popup _after_ is has been displayed, but I can't seem to find the switch to turn this feature off. Thanks, patrick -- Patrick Machielse Hieper Software http://www.hieper.nl i...@hieper.nl ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Pointer was being free was not allocated
Also, Xcode's built-in Analyze menu item might catch some of those. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de On Feb 13, 2013, at 10:36 PM, Sean McBride s...@rogue-research.com wrote: On Wed, 13 Feb 2013 19:50:29 +0800, anni saini said: Can anybody know how to resolve the issue of Pointer was being free was not allocated I was facing this issue with my project on 10.7 and 10.8 however the code works perfectly fine on 10.6. Any idea what is causing this? There are lots of great debug tools to track this kind of thing down. Search for: valgrind, guard malloc, address sanitizer. Cheers, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/witness.of.teachtext%40gmx.net This email sent to witness.of.teacht...@gmx.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
I wrote a -deepCopy method as part of a protocol on the common collection classes. It does a respondsToSelector: and calls -copy if it doesn't. So as long as my collection views cover all collection classes to create a new NSArray etc. containing copies of the same objects, it mostly works. Downsides: This will make immutable copies of mutable objects (if you called -mutableCopy where available, you might do the reverse), and you need to be careful that you don't miss adding -deepCopy to a class. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de On Feb 14, 2013, at 3:07 AM, James Maxwell jbmaxw...@rubato-music.com wrote: I've run into a situation where I really need a deep copy of an object. I've implemented this using Apple's recommended approach with NSKeyedArchiver/Unarchiver, and it's nice, simple, and functional. But it's also pretty darn slow -- as in a clear, subjectively apparent performance hit. Has anybody had to find a way around this, and if so, what did you do? Or if anybody just has a nice, creative thought about another way of doing it, I'd love to hear about it. The object(s) being copied are custom classes, and there's a chance I may be able to get away with copying only certain properties (i.e., rather than archiving the entire graph from the root object), so I'll look into making a deepCopy method that's more selective. But I'd appreciate any thoughts in the meantime. Thanks in advance. J. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/witness.of.teachtext%40gmx.net This email sent to witness.of.teacht...@gmx.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
What NSKeyedArchiver probably does is have a dictionary that maps the original object pointer values to the copied objects. So instead of just straight-out copying an object, it does: NSString* theKey = [NSString stringWithFormat: @%p, theOriginal]; id theCopy = [objectCopies objectForKey: theKey]; if( !theCopy ) { theCopy = [theOriginal copy]; [objectCopies setObject: theCopy forKey: theKey]; } That way, every object only gets copied once, and the copy re-used in other spots. That may be part of why it is slower. (NB - you could probably use an NSValue +valueWithUnretainedPointer: or whatever as the key, I just quickly typed this untested code into the e-mail) Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de On Feb 14, 2013, at 3:57 AM, Ken Thomases k...@codeweavers.com wrote: Your question prompted me to try to design an analog of NSKeyedArchiver, NSCode, and NSCoding that would generate the new object graph on the fly as it went instead of producing a data object. The idea is that the copier (the analog of the archiver/coder) would know which objects had already been copied and so would avoid over-duplicating them in the new graph. However, that ends up being hard because each object has to copy its related object before it's complete enough to be registered with the copier. So, it isn't successful in avoiding the potential for infinite recursion. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
On 14 Feb 2013, at 02:07, James Maxwell jbmaxw...@rubato-music.com wrote: I've run into a situation where I really need a deep copy of an object. I've implemented this using Apple's recommended approach with NSKeyedArchiver/Unarchiver, and it's nice, simple, and functional. But it's also pretty darn slow -- as in a clear, subjectively apparent performance hit. Has anybody had to find a way around this, and if so, what did you do? Or if anybody just has a nice, creative thought about another way of doing it, I'd love to hear about it. The object(s) being copied are custom classes, and there's a chance I may be able to get away with copying only certain properties (i.e., rather than archiving the entire graph from the root object), so I'll look into making a deepCopy method that's more selective. But I'd appreciate any thoughts in the meantime. One possible approach to this (though not one that's going to be as fast as a custom deepCopy method), would be to implement your own NSCoder subclass. I have in the past made keyed archivers which are substantially quicker than apple's, and encode into substantially smaller byte formats. Thanks Tom Davie ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
On Feb 14, 2013, at 8:30 AM, Uli Kusterer wrote: On Feb 14, 2013, at 3:57 AM, Ken Thomases k...@codeweavers.com wrote: Your question prompted me to try to design an analog of NSKeyedArchiver, NSCode, and NSCoding that would generate the new object graph on the fly as it went instead of producing a data object. The idea is that the copier (the analog of the archiver/coder) would know which objects had already been copied and so would avoid over-duplicating them in the new graph. However, that ends up being hard because each object has to copy its related object before it's complete enough to be registered with the copier. So, it isn't successful in avoiding the potential for infinite recursion. What NSKeyedArchiver probably does is have a dictionary that maps the original object pointer values to the copied objects. So instead of just straight-out copying an object, it does: NSString* theKey = [NSString stringWithFormat: @%p, theOriginal]; id theCopy = [objectCopies objectForKey: theKey]; if( !theCopy ) { theCopy = [theOriginal copy]; [objectCopies setObject: theCopy forKey: theKey]; } That way, every object only gets copied once, and the copy re-used in other spots. That may be part of why it is slower. (NB - you could probably use an NSValue +valueWithUnretainedPointer: or whatever as the key, I just quickly typed this untested code into the e-mail) That's what I considered but it doesn't work. You can't add the copy into the archiver's database of already-copied objects until it's complete. But, for the case where the graph has cycles, making the complete copy will try to make copies of all its related objects first. When the cycle loops back to the same original, that original still does not have a copy in the database, so it tries to make another copy. Infinite recursion. 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
On Feb 14, 2013, at 4:11 AM, Vyacheslav Karamov wrote: I need to implement NSTextView descendant similar to one used in Mac iMessages App. I have implemented live resizing, but how to set resizable image as its custom shape? AFAIK, custom text box geometry is really a function of NSTextContainer. I am pretty sure there are examples of this somewhere, but I don't expect it to be trivial. I have been neck-deep in the Cocoa text system and the documentation is somewhat less than desirable and requires having as full an understanding as possible of multiple documents that are not well cross-referenced. A good place to start is here: http://developer.apple.com/library/Mac/#documentation/Cocoa/Conceptual/TextStorageLayer/Concepts/LayoutGeometry.html Chances are, the work will be similar for most simple shapes, so googling for drawing text in a circle, for instance, might show enough sample code that you can figure out what is happening. Good luck, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is CoreData on iOS ready for prime time for serious work?
I've used Core Data a ton in apps since it was introduced on iOS. I've also used NSFetchedResultsController quite a bit and I've helped others with their Core Data code. One thing to keep in mind is that Core Data uses exceptions internally as part of its normal operation. If you break on exceptions, you'll end up in the debugger quite a bit but it's not because anything is broken, just the way Core Data is built. Annoying but important to remember. Your customers should not be impacted by this at all. Regarding crashes, by far the most common cause is improper use of Core Data and threads/queues. You mentioned using thread confinement - by that I assume you mean NSConfinementConcurrencyType and not something like NSPrivateQueueConcurrencyType? Have you considered using the newer NSPrivateQueueConcurrencyType and the performBlock methods? These enforce the threading rules even more explicitly and make it harder to make a mistake. For instance, if you init a MOC with thread confinement on the main thread even if you only use it on another thread, you're likely breaking the rules (MOCs created on the main thread hook into the run loop in special ways - make sure you are creating your MOCs on the thread/queue they are going to be used on). I've done several apps with what sounds like similar use cases and not had crashes or other problems so my guess is something may be slightly off… if you can use the new stuff, consider it. It's very helpful. Hope that helps somewhat. On Feb 13, 2013, at 11:34 PM, Laurent Daudelin laur...@nemesys-soft.com wrote: I just added CoreData to an app I'm working on. I've been working with CoreData for about a year, not exclusively but pretty regularly so I think I'm experienced enough to set it up properly. However, our testers are experiencing what I feel is more than normal crashes in the main part of the app that depends on CoreData. I'm using an NSFetchedResultsController to drive my main table view and that part seems very weak and will break or raise an exception at any time for any reason. I collecting those crashes that can be detected by TestFlight and there is no relation between them but they all resolve around CoreData or the main tableview. The heaviest load is when I get a bunch of data from a server that is turned into JSON objects and then saved to the database. There can be 200 pretty large dictionaries coming at once and they are all saved to the database in a serial queue, while at the same time, the fetched results controller sends the usual delegate messages to adds those rows to the table view. I would say that 80% of the time, it works just fine, but for about 20% of the loads, some involved object will raise an exception. Since I'm using multiple threads, and as recommended in the doc, I'm using the thread confinement method to perform the needed operations that involve the database and managed objects. I have one managed object context per thread, but there is really only one, in that serial queue, plus the one in the main thread. I implement the didReceiveManagedObjectContextSaveNotification: methods to merge the changes on the main thread, as recommended. I pass object IDs when I need to access a managed object context from one thread to another. Still, I feel there are way too many crashes. I have read from older messages that the fetched results controller could get confused when issuing updates, moves and inserts back in iOS 3 and 4. But I haven't found anything that would lead me to believe that these bugs are still present. But, are they? Is it safe to use this technology for some serious database work? Any advice, pointer or info would be greatly appreciated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
On Feb 14, 2013, at 3:11 AM, Vyacheslav Karamov ubuntul...@yandex.ru wrote: Hello All! I need to implement NSTextView descendant similar to one used in Mac iMessages App. I have implemented live resizing, but how to set resizable image as its custom shape? Messages doesn't use custom-shaped text views. If you're referring to the bubbles around sent messages, that's purely visual, and it's actually a web view. 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: https://lists.apple.com/mailman/options/cocoa-dev/kyle%40ksluder.com This email sent to k...@ksluder.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
I've taken the plunge and written a mutable deep copy method for NSObject in my applications. So far, I've used it only to add interesting arbitrary objects to NSError userInfo dictionaries. Unliike Ken and Uli, I'd never thought about the circular references in object trees, but I ran into a different problem, which you should also watch out for, which is that descendant objects are not necessarily serializable, encodeable, or respond to -mutableCopy. https://github.com/jerrykrinock/CategoriesObjC/blob/master/NSObject%2BDeepCopy.h My next commit of that will have at least some warnings about circular references in object trees :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is CoreData on iOS ready for prime time for serious work?
On Feb 14, 2013, at 9:03 AM, Hunter Hillegas li...@lastonepicked.com wrote: One thing to keep in mind is that Core Data uses exceptions internally as part of its normal operation. If you break on exceptions, you'll end up in the debugger quite a bit but it's not because anything is broken, just the way Core Data is built. Annoying but important to remember. Your customers should not be impacted by this at all. I've added a feature request against Xcode to provide a means to ignore certain exceptions, such as those which occur on certain threads completely owned by Apple—I suggested ignoring based on thread name—such as the ones utilized by SSL and sockets, which gets really noisy during certificate handshakes. Feel free to add your own and maybe CoreData won't be so noisy in the next release. -- Gary L. Wade (Sent from my iPhone) http://www.garywade.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UI_APPEARANCE_SELECTOR question
One more question I hope. I've got the below working great, so I started using it in other places within my code - specifically for some sub-classed UITableViewCells: //appearance settings @property (nonatomic, assign) NSInteger showDateLabel UI_APPEARANCE_SELECTOR; @property (nonatomic, assign) NSInteger showPillView UI_APPEARANCE_SELECTOR; I'm using it in - (void)layoutSubviews and all seems fine - they are set to 1 when I load the cells in the table view. However when I push a controller onto the stack and then pop it back, the table cells now within the layoutSubViews show the properties as 0. I've double checked everywhere and I'm not setting these properties anywhere except in the appearance proxy. I'm sure there are some assumptions I'm making that may not be correct, but any help would be appreciated. On Feb 8, 2013, at 2:42 PM, Luke the Hiesterman luket...@apple.com wrote: Appearance customizations get applied at layout time, so your view simply hasn't had the appearance applied yet in -initWithFrame:. That's why self.tabFont is nil. Luke On Feb 8, 2013, at 1:38 PM, Alex Kac a...@webis.net wrote: Trying to see if I understand this correctly and what I may be doing wrong. I have a tab bar project that is in my workspace and I've added this to its font property: UI_APPEARANCE_SELECTOR as such: @interface AKTabBarButton : UIView { } @property (nonatomic, strong) UIFont *tabFont UI_APPEARANCE_SELECTOR; - (id)initWithTabBarItem:(AKTabBarItem*)item; @end Within the initWithFrame: method: label.font = self.tabFont ? self.tabFont : [UIFont boldSystemFontOfSize:10]; and in code before we ever create any tab bars: [[AKTabBarButton appearance] setTabFont:[UIFont boldSystemFontOfSize:12]]; However self.tabFont is always nil. Its never getting my customized font. All the articles/websites/devforum pages I've read say that this is all I should have to do, but as something that's not documented much I'm not seeing how its supposed to work. I'd love any tips or pointers on what I'm doing wrong. Alex Kac - President and Founder Web Information Solutions, Inc. Forgiveness is not an occasional act: it is a permanent attitude. -- Dr. Martin Luther King ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is CoreData on iOS ready for prime time for serious work?
Thanks, Hunter. I'll consider the newer option. -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/ Logiciels Nemesys Software laur...@nemesys-soft.com On Feb 14, 2013, at 09:03, Hunter Hillegas li...@lastonepicked.com wrote: I've used Core Data a ton in apps since it was introduced on iOS. I've also used NSFetchedResultsController quite a bit and I've helped others with their Core Data code. One thing to keep in mind is that Core Data uses exceptions internally as part of its normal operation. If you break on exceptions, you'll end up in the debugger quite a bit but it's not because anything is broken, just the way Core Data is built. Annoying but important to remember. Your customers should not be impacted by this at all. Regarding crashes, by far the most common cause is improper use of Core Data and threads/queues. You mentioned using thread confinement - by that I assume you mean NSConfinementConcurrencyType and not something like NSPrivateQueueConcurrencyType? Have you considered using the newer NSPrivateQueueConcurrencyType and the performBlock methods? These enforce the threading rules even more explicitly and make it harder to make a mistake. For instance, if you init a MOC with thread confinement on the main thread even if you only use it on another thread, you're likely breaking the rules (MOCs created on the main thread hook into the run loop in special ways - make sure you are creating your MOCs on the thread/queue they are going to be used on). I've done several apps with what sounds like similar use cases and not had crashes or other problems so my guess is something may be slightly off… if you can use the new stuff, consider it. It's very helpful. Hope that helps somewhat. On Feb 13, 2013, at 11:34 PM, Laurent Daudelin laur...@nemesys-soft.com wrote: I just added CoreData to an app I'm working on. I've been working with CoreData for about a year, not exclusively but pretty regularly so I think I'm experienced enough to set it up properly. However, our testers are experiencing what I feel is more than normal crashes in the main part of the app that depends on CoreData. I'm using an NSFetchedResultsController to drive my main table view and that part seems very weak and will break or raise an exception at any time for any reason. I collecting those crashes that can be detected by TestFlight and there is no relation between them but they all resolve around CoreData or the main tableview. The heaviest load is when I get a bunch of data from a server that is turned into JSON objects and then saved to the database. There can be 200 pretty large dictionaries coming at once and they are all saved to the database in a serial queue, while at the same time, the fetched results controller sends the usual delegate messages to adds those rows to the table view. I would say that 80% of the time, it works just fine, but for about 20% of the loads, some involved object will raise an exception. Since I'm using multiple threads, and as recommended in the doc, I'm using the thread confinement method to perform the needed operations that involve the database and managed objects. I have one managed object context per thread, but there is really only one, in that serial queue, plus the one in the main thread. I implement the didReceiveManagedObjectContextSaveNotification: methods to merge the changes on the main thread, as recommended. I pass object IDs when I need to access a managed object context from one thread to another. Still, I feel there are way too many crashes. I have read from older messages that the fetched results controller could get confused when issuing updates, moves and inserts back in iOS 3 and 4. But I haven't found anything that would lead me to believe that these bugs are still present. But, are they? Is it safe to use this technology for some serious database work? Any advice, pointer or info would be greatly appreciated. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/laurent%40nemesys-soft.com This email sent to laur...@nemesys-soft.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS Document Interaction Technology
On Feb 13, 2013, at 6:30 PM, Jerry Krinock je...@ieee.org wrote: But I'm only writing as an iPad user. FYI: Document Interaction Programming Topics for iOS Registering the File Types Your App Supports If your app is capable of opening specific types of files, you should register that support with the system. This allows other apps, through the iOS document interaction technology, to offer the user the option to hand off those files to your app. To declare its support for file types, your app must include the CFBundleDocumentTypes key in its Info.plistproperty list file. (See “Core Foundation Keys”.) The system adds this information to a registry that other apps can access through a document interaction controller. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
Hi all, Anyone tried using NSNetService and NSNetServiceBrowser on non-main threads on OS X? - the 'Thread Safety Summary' document does not mention these classes. - NSNetServices.h says NSNetService instances may be scheduled on NSRunLoops to operate in different modes, or in other threads. It is generally not necessary to schedule NSNetServices in other threads. - CFNetServices.h documents pretty much every API as 'Thread safe', and if the NS version is a wrapper over the CF version... (actually, I can't find a doc saying these are toll free bridged either.) I've having intermitting issues where my delegate methods are sometimes not being called, and I wonder if it's because I'm using a non-main thread/runloop. Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: UI_APPEARANCE_SELECTOR question
OK I think I figured it out. There are several layout calls to the UITableViewCell (the parent view controller is doing a reload on certain rows on a data change), and those first 2 or so layout calls the appearance proxy is nil, but on the third its there and gives me the correct info. I had some bad logic in my code that just made the first 2 calls set other variables it shouldn't have. So I've found/fixed my issue. On Feb 14, 2013, at 11:06 AM, Alex Kac a...@webis.net wrote: One more question I hope. I've got the below working great, so I started using it in other places within my code - specifically for some sub-classed UITableViewCells: //appearance settings @property (nonatomic, assign) NSInteger showDateLabel UI_APPEARANCE_SELECTOR; @property (nonatomic, assign) NSInteger showPillView UI_APPEARANCE_SELECTOR; I'm using it in - (void)layoutSubviews and all seems fine - they are set to 1 when I load the cells in the table view. However when I push a controller onto the stack and then pop it back, the table cells now within the layoutSubViews show the properties as 0. I've double checked everywhere and I'm not setting these properties anywhere except in the appearance proxy. I'm sure there are some assumptions I'm making that may not be correct, but any help would be appreciated. On Feb 8, 2013, at 2:42 PM, Luke the Hiesterman luket...@apple.com wrote: Appearance customizations get applied at layout time, so your view simply hasn't had the appearance applied yet in -initWithFrame:. That's why self.tabFont is nil. Luke On Feb 8, 2013, at 1:38 PM, Alex Kac a...@webis.net wrote: Trying to see if I understand this correctly and what I may be doing wrong. I have a tab bar project that is in my workspace and I've added this to its font property: UI_APPEARANCE_SELECTOR as such: @interface AKTabBarButton : UIView { } @property (nonatomic, strong) UIFont *tabFont UI_APPEARANCE_SELECTOR; - (id)initWithTabBarItem:(AKTabBarItem*)item; @end Within the initWithFrame: method: label.font = self.tabFont ? self.tabFont : [UIFont boldSystemFontOfSize:10]; and in code before we ever create any tab bars: [[AKTabBarButton appearance] setTabFont:[UIFont boldSystemFontOfSize:12]]; However self.tabFont is always nil. Its never getting my customized font. All the articles/websites/devforum pages I've read say that this is all I should have to do, but as something that's not documented much I'm not seeing how its supposed to work. I'd love any tips or pointers on what I'm doing wrong. Alex Kac - President and Founder Web Information Solutions, Inc. To educate a person in mind and not in morals is to educate a menace to society. -- Theodore Roosevelt ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
No, I have already implemented bubbles. It is just NSTableView descendant. 14.02.2013 19:13, Kyle Sluder пишет: On Feb 14, 2013, at 3:11 AM, Vyacheslav Karamov ubuntul...@yandex.ru wrote: Hello All! I need to implement NSTextView descendant similar to one used in Mac iMessages App. I have implemented live resizing, but how to set resizable image as its custom shape? Messages doesn't use custom-shaped text views. If you're referring to the bubbles around sent messages, that's purely visual, and it's actually a web view. This email sent to k...@ksluder.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
I know how to implement custom text layout. Good example of this I have found in Cocoa Programming Developer's Handbook by David Chisnall. This book gives an example how to implement custo text layout, but I don't understand how to implement custom shape of NSTextView. Because my widget grow in height while user is typing, custom image should also grow and vertical scrollbar appears if needed. Anyway, thank you for the quick response! Good luck, Vyacheslav. 14.02.2013 18:56, Keary Suska пишет: On Feb 14, 2013, at 4:11 AM, Vyacheslav Karamov wrote: I need to implement NSTextView descendant similar to one used in Mac iMessages App. I have implemented live resizing, but how to set resizable image as its custom shape? AFAIK, custom text box geometry is really a function of NSTextContainer. I am pretty sure there are examples of this somewhere, but I don't expect it to be trivial. I have been neck-deep in the Cocoa text system and the documentation is somewhat less than desirable and requires having as full an understanding as possible of multiple documents that are not well cross-referenced. A good place to start is here: http://developer.apple.com/library/Mac/#documentation/Cocoa/Conceptual/TextStorageLayer/Concepts/LayoutGeometry.html Chances are, the work will be similar for most simple shapes, so googling for drawing text in a circle, for instance, might show enough sample code that you can figure out what is happening. Good luck, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
On Thu, Feb 14, 2013, at 12:00 PM, Vyacheslav Karamov wrote: I know how to implement custom text layout. Good example of this I have found in Cocoa Programming Developer's Handbook by David Chisnall. This book gives an example how to implement custo text layout, but I don't understand how to implement custom shape of NSTextView. Because my widget grow in height while user is typing, custom image should also grow and vertical scrollbar appears if needed. Anyway, thank you for the quick response! Okay, you need to elaborate what you mean by custom shape. Do you just want your roughtly-rectangular text field to draw with a rounded corners or something? --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView with irregular shape
I want the same text view as Apple iMessages has. I have such bullet image and I plan to use it as textview's shape. Actually this one http://i.piccy.info/i7/e52f246522784139d1c75bf53bb466e6/4-55-1897/58781878/iMessages.png 14.02.2013 22:18, Kyle Sluder пишет: On Thu, Feb 14, 2013, at 12:00 PM, Vyacheslav Karamov wrote: I know how to implement custom text layout. Good example of this I have found in Cocoa Programming Developer's Handbook by David Chisnall. This book gives an example how to implement custo text layout, but I don't understand how to implement custom shape of NSTextView. Because my widget grow in height while user is typing, custom image should also grow and vertical scrollbar appears if needed. Anyway, thank you for the quick response! Okay, you need to elaborate what you mean by custom shape. Do you just want your roughtly-rectangular text field to draw with a rounded corners or something? --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
On 14 Feb 2013, at 11:26 AM, Sean McBride s...@rogue-research.com wrote: Anyone tried using NSNetService and NSNetServiceBrowser on non-main threads on OS X? - the 'Thread Safety Summary' document does not mention these classes. - NSNetServices.h says NSNetService instances may be scheduled on NSRunLoops to operate in different modes, or in other threads. It is generally not necessary to schedule NSNetServices in other threads. - CFNetServices.h documents pretty much every API as 'Thread safe', and if the NS version is a wrapper over the CF version... (actually, I can't find a doc saying these are toll free bridged either.) I've having intermitting issues where my delegate methods are sometimes not being called, and I wonder if it's because I'm using a non-main thread/runloop. NSNetService (and NSNetServiceBrowser) automatically schedules itself on the run loop of the thread it's being created on. If the run loop isn't being spun (e.g. on a thread created by detaching a pthread or an NSThread) then you won't get callbacks. .chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Thread safety of Bonjour Cocoa classes? (NSNetService, etc.)
On Thu, 14 Feb 2013 12:47:13 -0800, Chris Parker said: NSNetService (and NSNetServiceBrowser) automatically schedules itself on the run loop of the thread it's being created on. If the run loop isn't being spun (e.g. on a thread created by detaching a pthread or an NSThread) then you won't get callbacks. Chris, Thanks for your reply. I create an NSThread with initWithTarget:selector:object: then from the thread's entry function I do [[NSRunLoop currentRunLoop] run] to create and run its runloop forever. The API to my class uses performSelector:onThread: to do all work (like the creation of the NSNetService and NSNetServiceBrowser) on my thread. Does that sound kosher? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
The Objective-C Programming Language
I was trying to answer a question for a Cocoa beginner today and realized it's been a long time since I looked at the Apple docs from the point of view of someone new to Objective-C. What happened to The Objective-C Programming Language? As I recall that was *the* place to get someone started with the language. There are many references to that title still in the docs that no longer link anywhere. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: The Objective-C Programming Language
On Feb 14, 2013, at 2:40 PM, Andy Lee ag...@mac.com wrote: I was trying to answer a question for a Cocoa beginner today and realized it's been a long time since I looked at the Apple docs from the point of view of someone new to Objective-C. What happened to The Objective-C Programming Language? As I recall that was *the* place to get someone started with the language. There are many references to that title still in the docs that no longer link anywhere. I believe it has been renamed Programming with Objective-C. Preston ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
On 14/02/2013, at 1:07 PM, James Maxwell jbmaxw...@rubato-music.com wrote: I've run into a situation where I really need a deep copy of an object. My question would be: are you really sure? Yes, there are times you need a deep copy, but surprisingly few. Often you can redesign your code not to need one --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Recursive file copy with good progress data?
Hi all, I'm writing a tool that needs to copy directories with a lot of files and a significant hierarchy (a home directory is a good analog). I've implemented test versions of the following: a. NSTask'ing rsync. This works but provides terrible progress, as I have to parse the the made-for-human output. b. FSCopyObjectAsync. This provides excellent progress via its callback - bytes transferred/to go/total, file count, and even a rough estimate of throughput, but it also immediately stopped when it hit an unexpected thing - I think a UNIX socket - even with kFSFileOperationSkipSourcePermissionErrors set. Oh and it's deprecated in 10.8. c. copyfile. Seems to be solid, provides the callback the ability to note an error and continue working, but has poor progress status. I can't tell how many bytes have been written: the callback is only sometimes called for individual file progress, so I can't keep a running sum of bytes. I could keep a running sum of files, but I will also have to do my own traversal to count them in the first place. Is there anything that provides the level of progress that FSCopyObjectAsync does but gives the callback more control like copyfile() does? Thanks, --Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
On 15 Feb 2013, at 01:25, Ken Thomases k...@codeweavers.com wrote: On Feb 14, 2013, at 8:30 AM, Uli Kusterer wrote: On Feb 14, 2013, at 3:57 AM, Ken Thomases k...@codeweavers.com wrote: Your question prompted me to try to design an analog of NSKeyedArchiver, NSCode, and NSCoding that would generate the new object graph on the fly as it went instead of producing a data object. The idea is that the copier (the analog of the archiver/coder) would know which objects had already been copied and so would avoid over-duplicating them in the new graph. However, that ends up being hard because each object has to copy its related object before it's complete enough to be registered with the copier. So, it isn't successful in avoiding the potential for infinite recursion. What NSKeyedArchiver probably does is have a dictionary that maps the original object pointer values to the copied objects. So instead of just straight-out copying an object, it does: NSString* theKey = [NSString stringWithFormat: @%p, theOriginal]; id theCopy = [objectCopies objectForKey: theKey]; if( !theCopy ) { theCopy = [theOriginal copy]; [objectCopies setObject: theCopy forKey: theKey]; } That way, every object only gets copied once, and the copy re-used in other spots. That may be part of why it is slower. (NB - you could probably use an NSValue +valueWithUnretainedPointer: or whatever as the key, I just quickly typed this untested code into the e-mail) That's what I considered but it doesn't work. You can't add the copy into the archiver's database of already-copied objects until it's complete. But, for the case where the graph has cycles, making the complete copy will try to make copies of all its related objects first. When the cycle loops back to the same original, that original still does not have a copy in the database, so it tries to make another copy. Infinite recursion. Why not keep a mutable dictionary M and on encountering an object (in the scanning phase) do: if object not in mutable dictionary M then add to M: key = address of object, value = NSNull continue walking the object tree else do nothing endif And in the second (copy) phase do: if value of object = NSNull then copy it and set the value in M to the copied object else just store a link to the already copied object. Should work with cycles. Might not be faster than NSArchive. Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: faster deep copies?
Well, yes, that's a good question. But I spent a good deal of time trying to find a way around it and couldn't. However, in the meantime I discovered that by using a home-spun -deepCopy method on just a couple of classes I was able to solve my mutation problem, without resorting to the wholesale NSKeyedArchiver approach of grabbing the entire object graph. So, problem solved. If I ever feel inclined to discover a deeper fix I will, but it won't be any time soon! J. On 2013-02-14, at 4:01 PM, Graham Cox graham@bigpond.com wrote: On 14/02/2013, at 1:07 PM, James Maxwell jbmaxw...@rubato-music.com wrote: I've run into a situation where I really need a deep copy of an object. My question would be: are you really sure? Yes, there are times you need a deep copy, but surprisingly few. Often you can redesign your code not to need one --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Recursive file copy with good progress data?
On 15/02/2013, at 1:55 PM, Jim Zajkowski jim.zajkow...@gmail.com wrote: s there anything that provides the level of progress that FSCopyObjectAsync does but gives the callback more control like copyfile() does? You could look into NSFileManager's -copyItemAtURL:toURL:error: method which, in conjunction with a delegate implementing appropriate methods, gives you both progress feedback as well as a mechanism for error recovery. Not sure what performance will be like though. --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com