Re: table view and custom cell optimization problem
On Mar 3, 2011, at 23:54, Nick Rogers wrote: > But the problem is that I don't have anything common in the rows. > The image (128x128) are different, the four lines of text are different and > the lines I draw are different in each cell. On 3 Mar 2011, at 04:06, Nick Rogers wrote: > I have a table view with the custom cell class assigned to its only column in > awakeFromNib method using setDataCell:. > Then I'm doing some drawing in drawInteriorWithFrame: of the NSCell subclass. > The problem is that drawing include four lines of text and an image and a few > lines using NSBezierPath. > > This is relatively time consuming and hence when I scroll the table view, the > scrolling is not that smooth and is a bit jerky. > > Is there a way to do all this custom drawing in a manner that could make the > scrolling faster. There's no particular reason why the drawing tasks you've described should be so slow as to interfere with scrolling, unless (for example) it's hitting the disk for every row. You have to find out why it's slow. Optimizing drawing that turns out not to be the problem is going to be an exercise in frustration, so better not to do that. This sounds like a job for Instruments. Or, you could certainly start by commenting out various parts of your drawing code and seeing if there's any obvious culprit. In this case, "what" needs to come before "why" and both of them before "how else". :) ___ 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: Outlets Not Connected In awakeFromNib
All, thank you for your replies. It made me re-read the Resource Programming Guide. And it works exactly as it is described (except that the description for -awakeFromNib in the Reference could be more accurate). Though, I have mixed feelings about how it works. Unfortunately, due to the problem described previously, -awakeFromNib does not seem to be always appropriate for its intended use as described in the reference. There are also subtle differences between iOS and Mac OS. On iOS, when using -viewDidLoad, we need to consider that it can possibly be called more than once in the life cycle for a controller, and may be created from within a nib or programmatically. This often requires extra care in this and possibly related methods, e.g. -viewDidUnload. So, unfortunately, there is no easier way. Andreas On Mar 3, 2011, at 5:57 PM, Kyle Sluder wrote: > On Thu, Mar 3, 2011 at 4:37 AM, Andreas Grosam wrote: >> At the time awakeFromNib is sent to the root view controller, the root view >> controller's outlets whose target exists in the main nib are connected. >> However, none of the outlets whose target objects exist in its corresponding >> nib "MyRootViewController nib" are connected. >> >> There is nothing in the docs mentioning this case. > > -awakeFromNib is sent to every object in the nib after all the > connections defined in the nib have been established. Since cross-nib > connections are not allowed, the documentation has no need to mention > your scenario. > > Perhaps the documentation should be rephrased to say "all connections > defined in the nib are guaranteed to have been reestablished" rather > than guaranteeing that all outlets have been connected, which is > inaccurate. > > On Thu, Mar 3, 2011 at 4:27 AM, Andreas Grosam wrote: >> When -awakeFromNib is sent to the root view controller, the outlet >> 'testView' is not connected. The message is sent during *loading the main >> nib*. The root view controller does not receive another -awakeFromNib >> message. > > From the Resource Programming Guide: > > "In iOS, this message [-awakeFromNib] is sent only to the interface > objects that were instantiated by the nib-loading code. It is not sent > to File’s Owner, First Responder, or any other proxy objects." > > So the answer to your problem is use the UIViewController methods to > find out when your RootViewController has loaded its view. > > --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: table view and custom cell optimization problem
On 4 Mar 2011, at 07:54, Nick Rogers wrote: > Hi, > Thanks for the reply. > > But the problem is that I don't have anything common in the rows. > The image (128x128) are different, the four lines of text are different and > the lines I draw are different in each cell. > > Any Ideas? > I use customised cell classes (non optimised) that contain beziers and gradient fills that definitely impact on performance. But in that case each cell in column has a separate background that could be cached as I described. Anyhow, Quincey has given you good advice on how to proceed. Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.com___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
API to check if the screen is zoomed
Hi, I am developing an Desktop application in which I want to perform some operation if the System screen is zoomed. Is there any API to identify if the screen is zoomed or not. If notification is the solution that will not work for me. Because, the screen might have been zoomed before my app is launched. Is there any way to handle this? 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
Accepting current edited text field contents
I have a window with a large number of editable text fields, and a big "Go" button. The text fields are bound to values in my class. At the moment if there is an edit of one of the values in progress and then I press "Go" then the "old" value for that field is the one in my class variable that is acted upon. In my view it would make a lot more sense to accept the current field text, probably while retaining the current selection in the edit session, and then act on the "Go" command. Is there a compact way of doing this? I have seen some rather convoluted code samples that accept the current edit session, but retaining the current selection looks to be very complicated, and require assumptions about the nature of the control involved. Surely there should be a more general one-line way of achieving this? Or is there a good UI argument why what I want is a bad idea? Any suggestions would be very welcome. Cheers Jonny___ 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: animating addSubview with iOS4
On Mar 3, 2011, at 8:16 PM, Matt Neuburg wrote: > Except that as Robert Vojta told you (and as Luke Hiesterman has clearly > stated on other occasions) it is wrong to assume that viewDidLoad means that > the view is now in the *interface*, or even that it is *about* to be put into > the interface, so it makes no sense to assume that an animation launched from > viewDidLoad, even with delayed performance, will be seen by the user. It > might appear to work, but it's still wrong. So this solution is incorrect: > >>> On Mar 2, 2011, at 12:42 PM, Andreas Grosam wrote: >>> - (void) viewDidLoad { // ... [self performSelector:@selector(addButtonWithAnimation) withObject:nil afterDelay:0.0]; } > The proper way to trigger an animation when the view first appears is in > viewDidAppear:, Matt, you are right, scheduling an action in -viewDidLoad is not the correct method for starting animations, and I did mention this. My suggestion was merely a quick fix to *test the animation* in the OPs *sample*. Nonetheless, I think there is an issue with certain animations started via transitionWithView:.. and transitionFromView:.. , please read on. Animations can be started only if the view has a window. When a view controller's view is loaded, it has not yet been assigned a super view, so there's also no window, and hence the animation wont start. So, when scheduling an animation via performSelector:withObject:afterDelay: there's no guarantee that the window is set when the method fires. So, after experiencing that the following UIView transition... animation - (void) addButtonWithAnimation { [UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionCurlUp animations:^{ [self.view addSubview:self.button]; } completion:NULL]; } will not work when invoked in -viewWillAppear. My first guess was, because the window - immediately after loading the view - is not yet set for the view, this might be the cause of the problem. But no: I looked a bit closer and -- become stumped: I found, that even invoking the same animation in -viewDidAppear will not work as well! (here, the window is set) More precisely, the "curlup" animation for the container view (self.view) is not showing. If however, the animation block has additional animations for style properties of self.button, these will be animated. It doesn't matter whether the button will be added in the animation block or has been added previously. It just happens that it worked when scheduled from the main thread via performSelector:withObject:afterDelay:. It also works when triggered from an action, invoked by a button tabbed by the user. Well, it should be noted that animations defined as: [self.view addSubview:animatedView]; CGAffineTransform transform = ... [UIView animateWithDuration:0.2 animations:^{ animatedView.transform = transform; } completion:NULL]; DO work when invoked in -viewDidAppear and -viewWillAppear. Likewise, it doesn't matter if the animated view will be added within the -viewDidAppear method or has been added previously. So it seems, there is a problem performing UIViewAnimationOptionTransition... animations for the UIView transitionWithView:... class method, and possibly for transitionFromView:... invoked from -viewWillAppear: and viewDidAppear:. Regards ___ 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: NSTableView: which delegate after a drag operation?
Hi Scott. Here are my two questions: 1) Which delegate can I use to inform table view B to update and reload its data when I have dragged an item inside table view A? If you’re adding it to the object array, you can easily do the update notification then. Thank you for your suggestion. Maybe this is just a stupid question, but what do you mean here with "the object array"? ---Ulf Dunkel ___ 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: NSXMLElement children doesn't return whitespace text nodes
That worked! Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML and found my answer, as well: Changes malformed XML into valid XML during processing of the document. It also eliminates “pretty-printing” formatting, such as leading tab characters. However, it respects the xmlns:space="preserve" attribute. (Input) Available in Mac OS X v10.4 and later. Declared in NSXMLNodeOptions.h. -Heath Borders heath.bord...@gmail.com Twitter: heathborders http://heath-tech.blogspot.com On Thu, Mar 3, 2011 at 10:33 PM, Gideon King wrote: > I recall that I had problems with that too, and IIRC, the > NSXMLNodePreserveWhitespace didn't seem to work, but right now I have > xml:space="preserve" in the XML and parse it with just the > NSXMLDocumentTidyXML option, and that works. I believe I just went through > all the combinations and permutations until I found that magic combination, > and have just stuck with it. > > HTH > > Regards > > Gideon > On 04/03/2011, at 3:02 AM, Heath Borders wrote: > >> I have the following xml: >> >> A foo. A bar. >> >> Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode? >> >> I've also tried changing my document thusly: >> >> A foo. A bar. >> >> I specify >> >> NSXMLNodePreserveWhitespace >> >> as my option to NSXMLDocument's >> >> initWithXMLString:options:error: >> >> selector. >> >> Thanks! >> > > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Accepting current edited text field contents
On Mar 4, 2011, at 03:40, Jonathan Taylor wrote: > I have a window with a large number of editable text fields, and a big "Go" > button. The text fields are bound to values in my class. At the moment if > there is an edit of one of the values in progress and then I press "Go" then > the "old" value for that field is the one in my class variable that is acted > upon. > > In my view it would make a lot more sense to accept the current field text, > probably while retaining the current selection in the edit session, and then > act on the "Go" command. Is there a compact way of doing this? I have seen > some rather convoluted code samples that accept the current edit session, but > retaining the current selection looks to be very complicated, and require > assumptions about the nature of the control involved. Surely there should be > a more general one-line way of achieving this? Or is there a good UI argument > why what I want is a bad idea? I really don't really understand the part about "the current edit session", but in general the solution is fairly straightforward -- you make use of NSController and its implementation of the NSEditor protocol. Instead of binding your text fields directly to your data model, bind them instead to a NSObjectController object in your NIB file, which is in turn bound to the data model. Then, in the action method of your Go button, first send one of the 2 'commitEditing...' methods to the NSObjectController. (One is synchronous and is used for reporting errors application-modally. The other is asynchronous and is used for reporting errors in a sheet on the offending window.) You'll also have to write code to deal with any text fields that refuse to accept their values, if that applies. Once the commit is done, proceed with your action normally. This will use the committed text field values. Nothing in any of this will or should have any effect on what's selected in the text field where editing was in progress. Why is retaining the current selection so complicated? ___ 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: Accepting current edited text field contents
On Mar 4, 2011, at 11:09, Quincey Morris wrote: > Instead of binding your text fields directly to your data model, bind them > instead to a NSObjectController object in your NIB file, which is in turn > bound to the data model. Just to clarify, in case you haven't used this trick before: -- You bind all of your text fields to the *same* NSObjectController. -- Bind the object controller through File's Owner to your data model. -- Use "selection" for the controller key on the object controller. (Unlike a NSArrayController, it's only bound to one content thing, so its selection is always that one thing.) -- Use the data model property key or key path as the model key on the object controller. (There's nothing wrong with using multiple object controllers, but it isn't necessary.) ___ 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: Accepting current edited text field contents
On 4 Mar 2011, at 19:09, Quincey Morris wrote: > On Mar 4, 2011, at 03:40, Jonathan Taylor wrote: > >> I have a window with a large number of editable text fields, and a big "Go" >> button. The text fields are bound to values in my class. At the moment if >> there is an edit of one of the values in progress and then I press "Go" then >> the "old" value for that field is the one in my class variable that is acted >> upon. >> >> In my view it would make a lot more sense to accept the current field text, >> probably while retaining the current selection in the edit session, and then >> act on the "Go" command. Is there a compact way of doing this? I have seen >> some rather convoluted code samples that accept the current edit session, >> but retaining the current selection looks to be very complicated, and >> require assumptions about the nature of the control involved. Surely there >> should be a more general one-line way of achieving this? Or is there a good >> UI argument why what I want is a bad idea? > > I really don't really understand the part about "the current edit session", > but in general the solution is fairly straightforward -- you make use of > NSController and its implementation of the NSEditor protocol. > > Instead of binding your text fields directly to your data model, bind them > instead to a NSObjectController object in your NIB file, which is in turn > bound to the data model. Then, in the action method of your Go button, first > send one of the 2 'commitEditing...' methods to the NSObjectController. (One > is synchronous and is used for reporting errors application-modally. The > other is asynchronous and is used for reporting errors in a sheet on the > offending window.) You'll also have to write code to deal with any text > fields that refuse to accept their values, if that applies. > > Once the commit is done, proceed with your action normally. This will use the > committed text field values. Thanks. I'll have a try with that. > Nothing in any of this will or should have any effect on what's selected in > the text field where editing was in progress. Why is retaining the current > selection so complicated? I don't know! The sample I saw (can't remember where now) did something which caused the text to be committed, but that had the side-effect of causing the text field to lose focus if I remember rightly. They then did some complicated application-specific stuff to restore the focus and selection to what it was. Evidently whoever wrote the sample did not know what they were doing! Thanks again for your help Jonny ___ 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: NSAttributedString crashes
On Mar 1, 2011, at 12:45 AM, Gerriet M. Denkmann wrote: > NSMutableAttributedString *attributedString = [ [ NSMutableAttributedString > alloc ] initWithString: firstChar ]; > [ attributedString fixFontAttributeInRange: NSMakeRange(0,[ attributedString > length ]) ]; > NSFont *aFont = [ attributedString attribute: NSFontAttributeName atIndex: 0 > effectiveRange: NULL ]; > NSLog(@"%s font1 %@",__FUNCTION__, aFont);// ok > NSString *fontName = [aFont fontName]; > [ attributedString release ]; > NSLog(@"%s FontName %@",__FUNCTION__, fontName); // ok > NSLog(@"%s font2 %@",__FUNCTION__, aFont);// writes (null) or crashes > > So obviously NSAttributedString does NOT return [ [ aFont retain ] > autorelease ] but just some internal pointer. > > Is this documented somewhere? No; you should log a bug requesting it to be documented. And/or, log a bug requesting the returned attributes be autoreleased. corbin ___ 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
XML Namespace Definitions on Non-Root Elements
I'm trying to parse a document with a namespace declared on a non-root element: http://example.com/foo";>This is an exemplary foo! I can read this xml into an NSXMLDocument just fine, but the following XPath query on root returns a non-nil, but empty NSArray: NSXMLNode *rootNode = ...// create my root node somehow NSArray *exampleFooElements = [rootNode nodesForXPath:@"/root/example:foo" error:nil]; // exampleFooElements != nil && [exampleFooElements count] == 0 However, if I add the namespace declaration to the root element, everything is fine: http://example.com/foo";>This is an exemplary foo! NSXMLNode *rootNode = ...// create my root node somehow NSArray *exampleFooElements = [rootNode nodesForXPath:@"/root/example:foo" error:nil]; // exampleFooElements != nil && [exampleFooElements count] == 1 I can do this change programmatically, but I'd rather not have to modify the document. This namespace usage should be legal. Am I doing something wrong? Thanks! -Heath Borders heath.bord...@gmail.com Twitter: heathborders http://heath-tech.blogspot.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: -[NSSet containsObject:] returns NO when it should return YES
Creating the NSNumber objects using unsignedLongLong instead of longLong solved my problem. Thanks to everyone who participated in the lively discussion. Sorry for being a little slow in closing the loop. -Michael On Feb 21, 2011, at 9:50 PM, Wim Lewis wrote: > > On 19 Feb 2011, at 2:17 PM, Michael Crawford wrote: >> Anyone have previous experience with this problem? Can you shed some light >> on where my thinking and assumptions are wrong. I could write a sweet of >> tests to try and prove/disprove what I think is happening but I'm hoping to >> benefit from someone else's pre-existing research, experiments, or internal >> knowledge. > > One thing to check is to find two NSNumbers which you think should be equal, > and see whether they return YES to -isEqual:. This is the form of equality > which NSSet is interested in. (-hash is an optimization.) > >> I also assumed that whether or not the value is signed or unsigned; negative >> or positive makes no difference as long as calling the same accessor method >> on both NSNumber instances returns the same result. > > I think this is the false assumption that is giving you grief. Calling an > accessor whose return type can't represent the NSNumber's value will return a > value which has been converted according to C's casting rules (as far as I > know). Consider two large numbers whose bottom 16 bits are the same; calling > -unsignedShortValue on them will return the same value, but you wouldn't > expect (or want) those numbers to compare equal. > > It looks like the contents of your noPlaySongs array were created using > numberWithLongLong:. Is there a reason not to use numberWithUnsignedLongLong: > to create them (as Greg Guerin suggests)? Or, ideally, never convert them to > a C integer representation in the first place and treat them as if they were > opaque objects (as Matt Neuburg suggests)? There's a fundamental difficulty, > which is that there is no C type which can represent the values of all > possible NSNumbers of integral types, (or even all C integers!), so > roundtripping the number through a plain integer type is fraught with peril > unless you know (or can figure out) which C type to use. > > > (IIRC, there are still a few small warts in NSNumber/CFNumber's behavior > which come from the fact that the numeric types implemented by CFNumber are > not compatible with the numeric types implemented by NSNumber, and yet > NSNumber is toll-free-bridged to CFNumber. I don't think this is related to > your problem, though.) > > ___ 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: NSButton disappears when I turn on "Wants Core Animation Layer" in IB
Marking the containing window for these view as visible-at-launch in IB seems to make all the difference. I previously had this option turned off because I did not want to display the main window until after app startup. I will try to figure exactly why this makes the difference but, again, if anyone has a clue, please chime in. -Michael On Mar 3, 2011, at 3:28 PM, Michael Crawford wrote: > I have a view with a few textured NSButton objects placed on top of a > contentView. Since a couple of the buttons overlap and one uses transparency > and requires a shadow, I turned on the wants-layer feature for that button. > The button still looks a little funky in the corner where it overlaps another > button, so I turn on wants-layer for the entire view by setting wants-layer > for the contentView containing the buttons. When I run the application, the > button with the shadow is invisible. It is there, I can click on it with the > mouse or press the key bound to the button and the app responds > appropriately. If I turn off wants-layer for the contentView and run the app > again, I can now see the button, though it looks wrong because of the missing > Core Animation features with transparency and shadow. > > The other half of the puzzle is that this view used to work fine. It broke > when I added a second window to the app, which also uses Core Animation. > > Anyone seen anything remotely like this? > > http://dl.dropbox.com/u/4920112/Screenshots/Screen%20shot%202011-03-03%20at%203.17.57%20PM.PNG > http://dl.dropbox.com/u/4920112/Screenshots/Screen%20shot%202011-03-03%20at%203.18.26%20PM.PNG > http://dl.dropbox.com/u/4920112/Screenshots/Screen%20shot%202011-03-03%20at%203.19.13%20PM.PNG > > -Michael > ___ > > 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/michaelacrawford%40me.com > > This email sent to michaelacrawf...@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: Accepting current edited text field contents
On 4 Mar 2011, at 19:25, Jonathan Taylor wrote: > > On 4 Mar 2011, at 19:09, Quincey Morris wrote: > >> On Mar 4, 2011, at 03:40, Jonathan Taylor wrote: >> >>> I have a window with a large number of editable text fields, and a big "Go" >>> button. The text fields are bound to values in my class. At the moment if >>> there is an edit of one of the values in progress and then I press "Go" >>> then the "old" value for that field is the one in my class variable that is >>> acted upon. >>> >>> In my view it would make a lot more sense to accept the current field text, >>> probably while retaining the current selection in the edit session, and >>> then act on the "Go" command. Is there a compact way of doing this? I have >>> seen some rather convoluted code samples that accept the current edit >>> session, but retaining the current selection looks to be very complicated, >>> and require assumptions about the nature of the control involved. Surely >>> there should be a more general one-line way of achieving this? Or is there >>> a good UI argument why what I want is a bad idea? >> >> I really don't really understand the part about "the current edit session", >> but in general the solution is fairly straightforward -- you make use of >> NSController and its implementation of the NSEditor protocol. >> >> Instead of binding your text fields directly to your data model, bind them >> instead to a NSObjectController object in your NIB file, which is in turn >> bound to the data model. Then, in the action method of your Go button, first >> send one of the 2 'commitEditing...' methods to the NSObjectController. (One >> is synchronous and is used for reporting errors application-modally. The >> other is asynchronous and is used for reporting errors in a sheet on the >> offending window.) You'll also have to write code to deal with any text >> fields that refuse to accept their values, if that applies. >> >> Once the commit is done, proceed with your action normally. This will use >> the committed text field values. > Thanks. I'll have a try with that. > >> Nothing in any of this will or should have any effect on what's selected in >> the text field where editing was in progress. Why is retaining the current >> selection so complicated? > I don't know! The sample I saw (can't remember where now) did something which > caused the text to be committed, but that had the side-effect of causing the > text field to lose focus if I remember rightly. They then did some > complicated application-specific stuff to restore the focus and selection to > what it was. Evidently whoever wrote the sample did not know what they were > doing! I think that the situation is that the when bindings are used the bound value may only get updated when the NSTextField looses first responder status (you may of course have continually updating bindings which should avoid the problem but validation may be more cumbersome). If you click an NSButton instance it doesn't take on first responder status so the binding doesn't get updated. Everything Quincey has said is correct about sending -commitEditing to the controller. If the first responder is in another view though then you might still have issues. In that case you use: [[[self view] window] makeFirstResponder:nil]; This ensures that the current first responder resigns and then makes the window its own first responder. This should be enough to trigger the binding to update. As for retaining the selection status (not that I know exactly what you mean) you can simply record the NSWindow -firstResponder id (or observe it for that matter on 10.6) and restore it after the commit. Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLElement children doesn't return whitespace text nodes
>From the Tree-Based XML Programming Guide: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/CreatingXMLDoc.html#//apple_ref/doc/uid/TP40001255-BCIGHBDI Preservation. The enum constants beginning with NSXMLNodePreserve support document fidelity. They allow you to ensure that aspects of the string XML input—for instance, quoting style of attribute values, CDATA sections, attribute and namespace order—remain the same when XML text is written out from the NSXMLDocument object. If you do not specify a preservation option for an aspect, NSXMLDocument handles it in a predetermined manner. For example, when NSXMLDocument reads in and parses an XML document, it normally strips white-space characters used in formatting (including tabs and carriage returns); however, if you specify NSXMLNodePreserveWhitespace these characters are kept hidden in the internal representation of the XML document. (“Hidden” means the white-space characters are retained for the output of the document, but are not visible within the tree representation.) Note that white space in text nodes is always preserved, and is not affected by the NSXMLNodePreserveWhitespace option. Notice the last sentence: Note that white space in text nodes is always preserved, and is not affected by the NSXMLNodePreserveWhitespace option. If my text node has non-whitespace in it, it gets recognized as a text node, and whitespace is preserved in the stringValue: A foo. a space on either side A bar. NSXMLElement *myTextElement = ... // get myText element somehow [myTextElement stringValue]; // returns " a space on either side " However: A foo. A bar. NSXMLElement *myTextElement = ... // get myText element somehow [myTextElement stringValue]; // returns "" (empty) This seems inconsistent with "Note that white space in text nodes is always preserved, and is not affected by the NSXMLNodePreserveWhitespace option." -Heath Borders heath.bord...@gmail.com Twitter: heathborders http://heath-tech.blogspot.com On Fri, Mar 4, 2011 at 9:40 AM, Heath Borders wrote: > That worked! > > Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML > and found my answer, as well: > > Changes malformed XML into valid XML during processing of the document. > It also eliminates “pretty-printing” formatting, such as leading tab > characters. However, it respects the xmlns:space="preserve" attribute. > (Input) > Available in Mac OS X v10.4 and later. > Declared in NSXMLNodeOptions.h. > > -Heath Borders > heath.bord...@gmail.com > Twitter: heathborders > http://heath-tech.blogspot.com > > > > On Thu, Mar 3, 2011 at 10:33 PM, Gideon King wrote: >> I recall that I had problems with that too, and IIRC, the >> NSXMLNodePreserveWhitespace didn't seem to work, but right now I have >> xml:space="preserve" in the XML and parse it with just the >> NSXMLDocumentTidyXML option, and that works. I believe I just went through >> all the combinations and permutations until I found that magic combination, >> and have just stuck with it. >> >> HTH >> >> Regards >> >> Gideon >> On 04/03/2011, at 3:02 AM, Heath Borders wrote: >> >>> I have the following xml: >>> >>> A foo. A bar. >>> >>> Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode? >>> >>> I've also tried changing my document thusly: >>> >>> A foo. A bar. >>> >>> I specify >>> >>> NSXMLNodePreserveWhitespace >>> >>> as my option to NSXMLDocument's >>> >>> initWithXMLString:options:error: >>> >>> selector. >>> >>> Thanks! >>> >> >> > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSXMLParser and entity resolving (OS X 10.6.6)
After spending a good deal of time with Uncle Google and some of his friends, I still have unanswered problems using NSXMLParser with an XML file that has entities in it. It appears that most of my questions have been asked over the last few years, but I haven't found any postings about a resolution to them. I'm hoping that someone can enlighten me as to whether I'm doing something wrong, or there's some unresolved bug in the class. The XML files I'm working with have HTML-like entities, such as and " in them. Without any changes to my XML delegate, this chokes it with the expected NSXMLParserUndeclaredEntityError (26) as I try to parse them. For example's sake, let's say I have this XML file: Why are there so many blank spaces? Because I love to use in addition to regular spaces With this, I get my error #26 after the first entity. My first attempt to remedy this was to implement -parser:resolveExternalEntityName:systemID: in my delegate object. This is successfully called, and I return (for these testing purposes) an NSData object to contain (using [@" " dataUsingEncoding:NSUTF8StringEncoding] to build the data). Looking in my -parser:foundCharacters: method I can see that this value gets passed back and the characters are "found" by the parser. But immediately after that I still get the undeclared entity error, and parsing fails. I tried this both with the parser set to resolve external entities and without, with the same results. I next looked to setting up the entities in a DTD, and references that directly in the XML file. I borrowed a DTD I found online that defined the HTML entities I needed (basically one that included for this test) and added the necessary lines in the XML to have it included. This had 3 effects: 1. I got notifications in my delegate for the foundInternalEntityDeclarationWithName notification. 2. My delegate stopped having its resolveExternalEntityName method called (not surprising given the fact that the parser was telling me that it was finding internal declarations). 3. I no longer got parse errors. BUT, nothing is being substituted in for the entities. I even went so far as to set up the DTD so that nbsp mapped to "a big test string", and confirmed that no substitutions were happening. My current stopgap is to do string replacements for the entities that I know are showing up. I would prefer to let the parser handle it, rather than have to look for and replace hundreds of HTML entities that most likely don't exist, but could. I'd greatly appreciate any help on resolving this; it seems like such a basic task that it shouldn't be a bug in NSXMLParser, but I can't see where I'm doing things wrong. Hopefully I've given enough information for someone to chip in and give me a hand. Thanks in advance. Greg ___ 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
Memory used by a UIImage?
Is there a way to determine how much memory a given UIImage is using for the in-memory image data? Thanks, Rick ___ 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: Memory used by a UIImage?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 3/4/11 2:18 PM, Rick Mann wrote: > Is there a way to determine how much memory a given UIImage is using for the > in-memory image data? Shot in the dark: access its CGImage to get the the underlying CGImageRef, then use the CGImage functions to calculate the size? - -- 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/ iD8DBQFNcW3uaOlrz5+0JdURAlrtAJ9osY3/iIOgdYECfub4qOkKmTXjywCeKhPh pNLs+rj6AnOY0dQ7bT/xuDI= =SPV4 -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
Question about Cocoa leaks
I asked a similar question to this one in the xcode-users list because I thought it related to Instruments but, actually, the question maybe has more to do with Cocoa. After reading the very interesting and informative blog from Bill Bumgarner (bbum) titled "When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth" and started testing an application that scans entire disks and gathers information about some of the items it scans. With such large number of allocations, I want to check that there are no memory leaks. Right now, I'm stumped at a few Cocoa classes that seem to be leaking. Not that much but still, I'd like to get to the bottom of this. In Instruments, I started my application with the Allocations tool. I did mark the heap after the application was started, then did a scan, closed the results window, marked the heap again and repeated 6 times (I had to stop at that time because Instruments was becoming very sluggish and all the free memory on my machine was used). In the last 5 heapshots, I notice a few Cocoa classes that seem to leak something. For example, given that instruction: pathToCompare = [destinationDirectoryPath stringByAppendingPathComponent:pathPartToAdd]; I get the following stack trace which leads to a calloc call and 400 bytes allocated: 0 libSystem.B.dylib calloc 1 libobjc.A.dylib _internal_class_createInstanceFromZone 2 libobjc.A.dylib _internal_class_createInstance 3 Foundation NSAllocateObject --- 1 frame omitted --- 5 Foundation -[NSString(NSPathUtilities) stringByAppendingPathComponent:] Or another occurrence with NSString: result = [NSString stringWithUTF8String:(char*)buffer]; generates this stack trace: 0 CoreFoundation _CFRuntimeCreateInstance --- 1 frame omitted --- 2 CoreFoundation CFStringCreateWithBytes 3 Foundation -[NSPlaceholderString initWithBytes:length:encoding:] 4 Foundation +[NSString stringWithUTF8String:] Even though the "buffer" is freed. Here is the complete instructions set: UInt8* buffer = malloc(4*PATH_MAX); if (FSRefMakePath(theRef, buffer, 4 * PATH_MAX - 1) == noErr) { result = [NSString stringWithUTF8String:(char*)buffer]; } free(buffer); So, can anybody explain what is going on here and whether I should be concerned by those leaks? For each heapshot, I scan 31770 items on disk and each heapshot results in between 8.84KB and 16.97KB leaked each time. The other strange observation is that there are exactly 14 instances of NSPathStore2 and 14 instances of CFString that are leaked in each heapshot even though the loop where the instructions above come from is iterated about 2,200 times. Basically, I scan the folder with 31,770 items in it and will retain 2,200 items of it that I process further. Anyone has any idea? I would think (and certainly hope) that Cocoa classes are thoroughly debugged and are run through extensive tests as to not waste memory. But, I can't understand how an instruction like stringByAppendingPathComponent: or stringWithUTF8String: can result in memory leaked. -Laurent. -- Laurent Daudelin AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/ Logiciels Nemesys Software 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView: which delegate after a drag operation?
On Mar 4, 2011, at 9:00 AM, Ulf Dunkel wrote: > Hi Scott. > >>> Here are my two questions: >>> >>> 1) Which delegate can I use to inform table view B to update and reload its >>> data when I have dragged an item inside table view A? >> >> If you’re adding it to the object array, you can easily do the update >> notification then. > > Thank you for your suggestion. Maybe this is just a stupid question, but what > do you mean here with "the object array”? No stupid questions, just incomplete answers. :-) If you’re adding the dragged data to your target table, that’s a good time to provide some notification that it needs to be updated. ___ 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: Question about Cocoa leaks
On Mar 4, 2011, at 17:54, Laurent Daudelin wrote: > So, can anybody explain what is going on here and whether I should be > concerned by those leaks? For each heapshot, I scan 31770 items on disk and > each heapshot results in between 8.84KB and 16.97KB leaked each time. The > other strange observation is that there are exactly 14 instances of > NSPathStore2 and 14 instances of CFString that are leaked in each heapshot > even though the loop where the instructions above come from is iterated about > 2,200 times. Basically, I scan the folder with 31,770 items in it and will > retain 2,200 items of it that I process further. What's the real question here? As pathology, leaking 8-16KB doesn't rate very high. I'm not suggesting you ignore this, but the detective task is (possibly) of a far subtler order than looking for something that's sucking up all of the system memory. (IIRC, you started this because each disk scan appeared to be consuming 300KB+ of memory. Did that problem go away?) What proportion of the 8-16KB is accounted for by the 14 instances of NSPathStore2 and CFString? All of it? If not, what is the rest of it? One of the list displays (sorry, I don't remember offhand which instrument, either Allocations or Object Graph, I think, but it's one of the choices from the popup just above the detail list) shows you the roots -- the objects that are keeping other objects alive. You *should* be able to track down what's keeping these 28 instances alive from there. If it's not your code, you'd probably be justified in ignoring them. What sort of object do you keep 2200 instances of, and do they have strong references that could be keeping other things alive? Do the 2200 instances disappear after each run as they should? Cocoa classes do leak things occasionally. It's just that small leaks don't necessarily get noticed, presumably depending on when in the internal testing cycle they get introduced. (There was, notoriously, a not-so-small leak in the Open/Save dialog code in one of the minor Leopard releases which had the unfortunate side effect of keeping some application objects -- NSDocument IIRC -- alive long after they should have been dead.) ___ 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: Memory used by a UIImage?
I doubt you could find out *exactly* how much memory is being used. You could probably get an approximation by multiplying pixelHeight * pixelWidth * 4 (assuming A, R, G, B channels), since the image bitmap is likely to be the biggest chunk for images of any real size. On Mar 4, 2011, at 2:18 PM, Rick Mann wrote: > Is there a way to determine how much memory a given UIImage is using for the > in-memory image data? ___ 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: Memory used by a UIImage?
Unfortunately, if I create the image from a PNG, it's possible iOS stores it compressed, and only decompresses when rendering. I'd like to know how much it's using at any given moment. Thanks, though. -- Rick On Mar 4, 2011, at 20:14:26, Steve Christensen wrote: > I doubt you could find out *exactly* how much memory is being used. You could > probably get an approximation by multiplying pixelHeight * pixelWidth * 4 > (assuming A, R, G, B channels), since the image bitmap is likely to be the > biggest chunk for images of any real size. > > > On Mar 4, 2011, at 2:18 PM, Rick Mann wrote: > >> Is there a way to determine how much memory a given UIImage is using for the >> in-memory image data? > ___ 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
Few question about iCal
Hi, Guys I am kind of want to extend the functionality of the iCal, like a plug-in or something. But I notice there is no offical plug-in SDK for iCal. I am thinking to develop a background app which will show a floating window when it detect the iCal is the front most app, this floating window should not affect the user use iCal (like not take the input focus away) ... Questions: 1, Any idea about how to make this floating window? 2, Is there a way to add customized data field into iCal event through CalendarStore or something like that?! Thanks Ivan Chen ___ 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
Contextual Menu plugin for Finder in Snow Leopard
Hi All, I want to develop a plugin for extending the functionality of the finder in snow leopard by adding the contextual menu to it. I couldn't find any resource or sample on the web, which provides some sort of help on my above queries. It's highly appreciated if someone could share his wisdom on how I can achieve this. Thanks in advance ! Best Regards: Vinay Jain vi...@metadesignsolutions.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: Contextual Menu plugin for Finder in Snow Leopard
On Fri, Mar 4, 2011 at 8:50 PM, Vinay Jain wrote: > Hi All, > > I want to develop a plugin for extending the functionality of the finder in > snow leopard by adding the contextual menu to it. > > I couldn't find any resource or sample on the web, which provides some sort > of help on my above queries. It's highly appreciated if someone could share > his wisdom on how I can achieve this. You cannot do this on Snow Leopard. Try writing a Service. --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
Want to write a service on contextual menu for finder
Hi All, I want to develop a service in snow leopard to add contextual menu to the finder. As i do research on, its not possible to add contextual menu in snow leopard directly. Instead i have to write a service for it. I got a tutorial of system services from the apple's website: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ SysServices/introduction.html I go through it, But this is not sufficient for me to start writing the service for it. I couldn't find any resource or sample on the web, which provides some sort of help on my above queries. It's highly appreciated if someone could share his wisdom on how I can achieve this. Thanks in advance ! Best Regards: Vinay Jain vi...@metadesignsolutions.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