Is FSEvents more efficient than polling?
There is a library I'm using that is reading a list of files every 0.5 seconds and watching for the last-modified attribute to change. Is this less efficient than using FSEvents? If so, how? For example, will it weak down the HDD or SSD faster? Run the battery of my laptop out sooner? Some other way? Thanks. -Steven ___ 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 FSEvents more efficient than polling?
An educated guess would be that polling should be less efficient as the event based FSEvents. Any reason you do not want to tap into the FSEvents API? You concerns about weakening is nothing I would consider, as you're talking about reading, which should be considered harmless (in the physical sense, not the performance point of view) -Michael On 28.04.2013, at 19:43, Steven Degutis wrote: > There is a library I'm using that is reading a list of files every 0.5 > seconds and watching for the last-modified attribute to change. > > Is this less efficient than using FSEvents? If so, how? For example, will > it weak down the HDD or SSD faster? Run the battery of my laptop out > sooner? Some other way? > > Thanks. > > -Steven > ___ > > 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/michael.starke%40hicknhack-software.com > > This email sent to michael.sta...@hicknhack-software.com ___m i c h a e l s t a r k e geschäftsführer HicknHack Software GmbH www.hicknhack-software.com ___k o n t a k t +49 (170) 3686136 cont...@hicknhack.com ___H i c k n H a c k S o f t w a r e G m b H geschäftsführer - maik lathan | andreas reischuck | michael starke bayreuther straße 32 01187 dresden amtsgericht dresden HRB 30351 sitz - dresden ___ 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 FSEvents more efficient than polling?
Let me give a little more context. The app is a Clojure test-auto-runner[1], that spins up the JVM and watches files to reload and re-run the tests for[2]. I'm concerned that running this auto-runner on my laptop is killing the SSD and battery quicker. Especially because these rMBPs don't have easily-replaceable parts, so once it's dead, it's probably dead for good. If it is a real concern, I have a plan. I previously wrote a little utility before called fswatch[3] that watches for changes and runs a script. I can just alter this stay open until you kill it, and print the changed files to stdout at every fs-event. Then I'd just open this process in Clojure and watch its stdout for files and reload when I see them. [1] https://github.com/slagyr/fresh/blob/master/src/fresh/core.clj [2] See the usage section in the URL "x-dictionary:preposition" [3] https://github.com/crh/fswatch On Sun, Apr 28, 2013 at 12:52 PM, Michael Starke wrote: > An educated guess would be that polling should be less efficient as the event > based FSEvents. > Any reason you do not want to tap into the FSEvents API? > > You concerns about weakening is nothing I would consider, as you're talking > about reading, which should be considered harmless (in the physical sense, > not the performance point of view) > > -Michael > > On 28.04.2013, at 19:43, Steven Degutis wrote: > >> There is a library I'm using that is reading a list of files every 0.5 >> seconds and watching for the last-modified attribute to change. >> >> Is this less efficient than using FSEvents? If so, how? For example, will >> it weak down the HDD or SSD faster? Run the battery of my laptop out >> sooner? Some other way? >> >> Thanks. >> >> -Steven >> ___ >> >> 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/michael.starke%40hicknhack-software.com >> >> This email sent to michael.sta...@hicknhack-software.com > > > ___m i c h a e l s t a r k e >geschäftsführer >HicknHack Software GmbH >www.hicknhack-software.com > > ___k o n t a k t >+49 (170) 3686136 >cont...@hicknhack.com > > ___H i c k n H a c k S o f t w a r e G m b H >geschäftsführer - maik lathan | andreas reischuck | michael starke >bayreuther straße 32 >01187 dresden >amtsgericht dresden HRB 30351 >sitz - dresden > > > ___ > > 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/sbdegutis%40gmail.com > > This email sent to sbdegu...@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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UITableViewCell with variable height
I'm having some problems to resize and show all text in a UITableViewCell based on the contents. It has two labels, the second of which can have a variable length and I'd like to show it all. So I added this code: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; { Note *n = [self.notes objectAtIndex: [indexPath row]]; CGSize constraint = CGSizeMake(320, 2000.0f); CGSize size = [n.content sizeWithFont: [UIFont systemFontOfSize: 14.0f] constrainedToSize: constraint lineBreakMode: NSLineBreakByWordWrapping]; CGFloat height = MAX(size.height, 44.0f); return height + 44.0f; } The problem is that the height of the cell is changing, but it still shows only one line of the second label. I have also set the numberOfLines to 0, which according to the docs "To remove any maximum limit, and use as many lines as needed, set the value of this property to 0." How can I fix this? Thanks, - Koen. ___ 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: UITableViewCell with variable height
Are you recalculating the size of the label as well? Using the same logic? I worked on the very same thing yesterday and that got it to work. In my case the label's content can be very large, with string length up to 12 characters and I found out that a label's recalculated size doesn't work well if the string's length is larger than 20.000... Op 28 apr. 2013, om 20:57 heeft Koen van der Drift het volgende geschreven: > I'm having some problems to resize and show all text in a UITableViewCell > based on the contents. It has two labels, the second of which can have a > variable length and I'd like to show it all. > > So I added this code: > > - (CGFloat)tableView:(UITableView *)tableView > heightForRowAtIndexPath:(NSIndexPath *)indexPath; > { >Note *n = [self.notes objectAtIndex: [indexPath row]]; > >CGSize constraint = CGSizeMake(320, 2000.0f); >CGSize size = [n.content sizeWithFont: [UIFont systemFontOfSize: 14.0f] > constrainedToSize: constraint > lineBreakMode: NSLineBreakByWordWrapping]; > >CGFloat height = MAX(size.height, 44.0f); > >return height + 44.0f; > } > > > The problem is that the height of the cell is changing, but it still shows > only one line of the second label. I have also set the numberOfLines to 0, > which according to the docs "To remove any maximum limit, and use as many > lines as needed, set the value of this property to 0." > > How can I fix this? > > Thanks, > > - Koen. > ___ > > 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/diederik%40tenhorses.com > > This email sent to diede...@tenhorses.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: UITableViewCell with variable height
On Apr 28, 2013, at 3:28 PM, Ten Horses | Diederik Meijer wrote: > Are you recalculating the size of the label as well? Using the same logic? Good call, that's the solution. Thanks, - Koen. ___ 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: Field editor in view-based table
On Fri, Apr 12, 2013, at 10:58 PM, Martin Hewitson wrote: > Dear list members, > > I have an NSTextField in a row view of a view-based tableview and I see > the following behavior: > > 1) to get the field editor to show I have to single click the text field > and wait about 1s. Do you have a double-click action specified for the table view? If so, NSTableView needs to wait to determine whether to send the click to the hit view. > 2) The field editor only shows if I click on a part of the text field > where this is text already, but if I click to the right of the current > text (but still within the text field) nothing happens. Are your text view's constraints/autoresizing mask set up correctly to stretch with the cell view? > 3) Double-clicking directly in the textfield does nothing. This might be related to the aforementioned double-click behavior. > 4) If the row is not selected, and I single click in the textfield, the > row is selected, but the field editor is not shown This is standard behavior for table views. --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: ^Block statement considered harmful for callbacks?
What's your proxy for NSTimer? I'm interesting in it. On 13-4-25 16:34, Oleg Krupnov wrote: Tom, I disagree, because unlike other objects with strong refs, or say @property(retain), the strong refs in blocks are created implicitly and it's just too easy to let them slip out of attention. There is no direct command to create the strong ref, unlike @property(retain). All you do is *mention* self or even an ivar, and voila, you're done. I wish there was a safe and elegant solution to this, like we did with proxy for NSTimer. On Thu, Apr 25, 2013 at 11:28 AM, Tom Davie wrote: On 25 Apr 2013, at 09:20, Oleg Krupnov wrote: Blocks in Obj-C seem convenient and powerful but in fact they are very dangerous because they retain all objects referenced from the block and thereby can implicitly create circular references. If you are not vigilant about every object you mention in the block, you can create one, two or more cycles of circular references causing your objects to never be freed afterwards. This breaks encapsulation of objects with block properties (e.g. MyAnimation.completionBlock) and forces the users of such objects to always keep in mind what they can, and what the cannot write in the block body, and still they can shoot themselves in the feet at any moment by losing vigilance. It seems to me that it's much better to drop the convenience of blocks in favor of safety and full control of retain/assign relationships between my objects. This is a shocker for me too, but I do not see a good solution to this problem. The solution suggested in Session 712 WWDC 2012 is ugly - call some kind of "cancel" method for every block when it's no longer needed. Even with ARC, declaring a weak ref to self and then strong ref to weak ref inside the block is ugly too - you have to add this crap to each and every block you write. Your argument can equally well be applied to any object that keeps strong references to other objects. It's not blocks that are doing any of the above, it's reference counting. And we know that the issues are there – we just choose to have them because the issues with the less leaky solutions are even more severe (especially in C like languages). 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/vipgs99%40gmail.com This email sent to vipg...@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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Laying out text in NSTextView around a subview
What I’m trying to do is have an NSTextView and add custom NSView subviews to it, but have it so the text can layout around the subviews. Right now, I can easily add a subview to the textview but of course, that goes into the textview and the text is ignorant of the subviews, so it just runs over/under the subview. Not what I’d like, of course. So I’d like to be able to add my own views at least in “block” (like when an HTML element is a block element, so it’s on its own line), and maybe “inline” as well (that is, a subview in line with the text, just like how an HTML element can be inline) although this is not absolutely required. I can’t quite figure out how to make this work. The only way I’ve seen that things can be added to a textview are with Text Attachments, but those seem relegated to only images/files, and only in an NSCell, which doesn’t contain (to my knowledge) an arbitrary NSView. I feel like this should be possible though, where do I start? Thanks! Jason Brennan ___ 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: Find functions disabled while NSSearchField is first responder.
On 27 Apr, 2013, at 08:04 , Antonio Nunes wrote: > On 25 Apr, 2013, at 18:21 , Antonio Nunes wrote: > >>> I have an NSSearchField, and a menu bar submenu with the standard Find >>> items. When the search field receives some input, it performs its action >>> and an array controller is filled with search results. Now, while the >>> search field is the first responder, none of the Find items are enabled, so >>> it is impossible to issue, say a Find Next command. The Find functions >>> perform fine when just about any other item in the document window is first >>> responder. I find that surprising, but, more importantly, I cannot find a >>> way to get the Find functions to work, while the search command has focus. >>> What am I missing? >> >> I added a search field to a small test project, to see if it works correctly >> in a less complicated setup, but to no avail. The Find menu items are still >> disabled. Some more googling (previous queries did not yield any relevant >> info), showed me that this issue has bitten others before, but no solutions >> appear to have been put forward. >> >> I've checked the responder chain, and tried to catch calls to >> validateMenuItem and validateUserInterfaceItem:, to see if I can find out >> the point at which these items are disabled. But the break points don't even >> trigger. When I check the window for its first responder, when the search >> field is receiving input, it returns the document window, not the search >> field. The document window though, has its own implementation of >> validateMenuItem:, but that is never called. >> >> How can I find out where the validation for performFindPanelAction: fails? > > Finally managed to solve this, and this is how I did it: (doesn't feel clean > or proper, but it works. If anyone knows of a better way to do this, I'm all > ears.) > > - In my NSDocument subclass, return a custom object (NSTextView subclass) for > the NSFieldEditor when the search field is activated: > > - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client > { >static NMD_SearchTextView *searchFieldEditor; > >if ( client == self.searchField ) { >if ( nil == searchFieldEditor ) { >searchFieldEditor = [[NMD_SearchTextView alloc] > initWithFrame:NSZeroRect]; >searchFieldEditor.document = self; // The object has a document > property to point to the NSDocument object, since we'll need that later. >} >return searchFieldEditor; >} >return nil; > } Oh dear, as someone pointed out off-list, there's a bug here: the document is only assigned once, when the searchFieldEditor variable is set the first time. The document should be assigned on every call: if ( client == self.searchField ) { if ( nil == searchFieldEditor ) { searchFieldEditor = [[NMD_SearchTextView alloc] initWithFrame:NSZeroRect]; } searchFieldEditor.document = self; // The object has a document property to point to the NSDocument object, since we'll need that later. return searchFieldEditor; } return nil; } > - Implement validateMenuItem: on the subclass to enable the relevant menu > items. > > - (BOOL)validateMenuItem:(NSMenuItem *)menuItem > { >if ( menuItem.action == @selector(performFindPanelAction:)) { >return menuItem.tag != NSFindPanelActionSetFindString; // No use > allowing "Use Selection for Find", since it will always be equal to the > current find string, where it exists. >} else { >return [super validateMenuItem:menuItem]; >} > } > > - Implement performFindPanelAction: to forward the action to the document. > > - (void)performFindPanelAction:(id)sender > { >[self.document performFindPanelAction:sender]; > } ___ 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
LSGetApplicationForURL() failed Error -10814
Hi, I am developing an application tool that requires a function which will give me users default browser name. I have code as below FSRef appRef; CFURLRef inUrl; OSStatus status; CFStringRef urlString; CFURLRef appUrlRef; CFStringRef defBrowserName; cfURLStr = CFStringCreateWithCString(kCFAllocatorDefault,"http:// www.apple.com", kCFStringEncodingUTF8); if (NULL == urlString)exit(-1); inUrl = CFURLCreateWithString(NULL, urlString, NULL); status = LSGetApplicationForURL(inUrl, kLSRolesEditor, &appRef, &appUrlRef); if (noErr != status) { CFRelease(inUrl); CFRelease (urlString); exit(-1); } defBrowserName = CFURLCopyLastPathComponent(inUrl); NSLog(@"Here is Default Browser Name %@", (NSString *)defBrowserName); This code works well when i am normal user. But when i ran same code as super user, it give me error that *LSGetApplicationForURL() failed. Error:(-10814)* Why this happened? I read about Launch Services Database. Now i am seeking for a solution to get default browser name. Is there no other way to get default browser name? If any other way provide me some help. Suggestions are welcome. Thanks in advance, Dhiraj ___ 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
Rotated CALayer and issues with coordinates (should I convert them manually?)
Hi guys, I've an NSView hierarchy with: - an NSWindow with inside an NSView (called BaseContainerView) (yellow color) - inside BaseContainerView another NSView called HostView (centered) (orange color) - inside HostView.layer a CALayer called subLayer (red color) Now, everything works well when I try convert coordinates through the hierarchy. That's my code: - (void) mouseDownOnBaseContainer:(NSNotification *) notif { NSEvent *theEvent = notif.object; // Location in NSWindow CGPoint locationInWindow = theEvent.locationInWindow; // Location is root NSView (baseContainerView) CGPoint locationInBaseContainer = [baseContainerView convertPoint:locationInWindow fromView:nil]; // Location in sub NSView (hostView) CGPoint locationInHostView = [baseContainerView convertPoint:locationInBaseContainer toView:hostView]; // Location in sub CALayer (child of hostView's layer, subLayer) CGPoint locationInSubLayer = [hostView.layer convertPoint:locationInHostView toLayer:subLayer]; NSLog(@"--- CLICK ---"); NSLog(@"NSWindow: {%0.0f,%0.0f}",locationInWindow.x,locationInWindow.y); NSLog(@"BaseContainerView: {%0.0f,%0.0f}",locationInBaseContainer.x,locationInBaseContainer.y); NSLog(@"HostView: {%0.0f,%0.0f}",locationInHostView.x,locationInHostView.y); NSLog(@"SubLayer: {%0.0f,%0.0f}",locationInSubLayer.x,locationInSubLayer.y); } If I try to rotate my hostView.layer (CALayer) using the function below I get wrong coordinates when I try to click at the same (rotated) point (the top,left coordinate of hostView) - (IBAction)btn_rotateHostView:(id)sender { isMovingToLandscape = !isMovingToLandscape; CALayer *hostViewLayer = hostView.layer; hostViewLayer.anchorPoint = CGPointMake(0.5f, 0.5f); // 0.5,0.5 made the center of the object hostViewLayer.frame = CGRectMake((NSWidth(baseContainerView.frame) - NSWidth(hostViewLayer.frame)) / 2.0f, (NSHeight(baseContainerView.frame) - NSHeight(hostViewLayer.frame)) / 2.0f, hostViewLayer.frame.size.width, hostViewLayer.frame.size.height); [CATransaction begin]; CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath: @"transform"]; CATransform3D rotateTransform = CATransform3DMakeRotation (DEGREES_TO_RADIANS (-90), 0, 0, 1); CATransform3D restoreTransform = CATransform3DIdentity; animation.fromValue = [NSValue valueWithCATransform3D: (isMovingToLandscape ? restoreTransform : rotateTransform)]; animation.toValue = [NSValue valueWithCATransform3D: (isMovingToLandscape ? rotateTransform : restoreTransform)]; animation.duration = 1.25; animation.cumulative = NO; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; [hostViewLayer addAnimation:animation forKey:@"transform"]; [CATransaction commit]; } This is a visual feeback: http://i.imgur.com/LYywXXL.png While here i've uploaded source code https://dl.dropboxusercontent.com/u/103260/TestinLayer.zip Should I convert coordinates manually? Or convertPoint: methods take in place rotation transform? I should expect 4,5 at the same "logical" point (top-left of rotated hostView) Any idea? ___ 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