Set up an editable view based NSTableView programmatically - how to?
Hi, I’d be very happy if somebody could point me to an example of an editable NSTableView set up programmatically. I searched the web, looked into TableViewPlayground etc. but could not come up with anything. I’d actually prefer to use bindings, but my first column should simply display the row numbers, for which I shouldn’t need a „real“ data source, just get the info from the table itself. To which I can’t bind in addition to my actual data source. Therefore my quest for pointers to a programatical setup. Thanks a lot, Peter ___ 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
Letting an instance know its own index within a container array - how to?
Rethinking the problem of how to display row numbers in a view based NSTableView from a different perspective: I could use bindings if I could manage to make my row entities know their index within the table view content array. As a solution I could device a delegate for my entities and make the entity order the delegate to send a query to the array controller about its own index in arranged objects. Does this seem like a sane approach? Thanks, Peter ___ 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
UINavigationBar.tintColor life on own?
I have an app where the navigation bar tint color starts to have an life on its own. Basic setup is that the app loads a document and in this document there is a key/value for the navigation bar tint color. In my basic “make up the content view” i also set the navigation bar color with self.navigationbar.tintcolor = something. That works as it should be. Now the user navigates around, pushes and pops other view controllers. Child view controllers of the root controller corectly inherit the tint color. At some time the user loads/exchanges another (second) document from the root view controller. Now I do my “make up the content view” again and set the navigation bar tint color to a new value. All child view controllers aren’t visibile but their nibs should be still loaded from the first document. (I have no memory warnings that would indicate an unload/purge). When the user now starts navigating again the child view controllers still have the tint color from the first document. This is also true if i do a second call on the UINavigationController appearance proxy. The child view controllers still have the color from the first document. Is there a reasonable way to correct this behaviour besides passing on the navigation bar color when pushing and popping child view controllers. Actually I do not have a reference to that vars in child view controllers, so it is not that easy for me to just read and set the tint color again an again. thx, ___ 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: Set up an editable view based NSTableView programmatically - how to?
On Jan 7, 2014, at 7:52 AM, Peter wrote: > I’d be very happy if somebody could point me to an example of an editable > NSTableView set up programmatically. It sounds like you just mean using a custom data source rather than relying on bindings to provide the data? That’s very easy to do. Just look at the docs for NSTableViewDataSource — you just need to implement the three methods to provide the row count, get a cell value, and set a cell value. —Jens ___ 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: Set up an editable view based NSTableView programmatically - how to?
Am 07.01.2014 um 17:32 schrieb Jens Alfke : > > On Jan 7, 2014, at 7:52 AM, Peter wrote: > >> I’d be very happy if somebody could point me to an example of an editable >> NSTableView set up programmatically. > > It sounds like you just mean using a custom data source rather than relying > on bindings to provide the data? That’s very easy to do. Just look at the > docs for NSTableViewDataSource — you just need to implement the three methods > to provide the row count, get a cell value, and set a cell value. > > —Jens Oops, sorry, the crucial info is only in the subject line: I meant a view based NSTableView. Which as far as I could find out does not make use of the NSTableViewDataSource protocol. I seems that you have to have to use delegate methods to make it work. ___ 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
Letting an instance know its own index within a container
If all you are trying to do is display row numbers, the only reasonable way I know is to use the table¹s delegates, then find and insert the row number for your table¹s number column. Doing it the way you stated would preclude display elsewhere if you needed that later. IMHO, it¹s preferable to use the table structure rather than trying to handle it in your data model. Of course, if you are creating separate elements for the table, based on your data model, you might be able to do something like that. On 1/7/14 11:32 AM, "cocoa-dev-requ...@lists.apple.com" wrote: > Rethinking the problem of how to display row numbers in a view based > NSTableView from a different perspective: I could use bindings if I could > manage to make my row entities know their index within the table view content > array. As a solution I could device a delegate for my entities and make the > entity order the delegate to send a query to the array controller about its > own index in arranged objects. Does this seem like a sane approach? ___ 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: Letting an instance know its own index within a container array - how to?
On Jan 7, 2014, at 9:09 AM, Peter wrote: > Rethinking the problem of how to display row numbers in a view based > NSTableView from a different perspective: > > I could use bindings if I could manage to make my row entities know their > index within the table view content array. > > As a solution I could device a delegate for my entities and make the entity > order the delegate to send a query to the array controller about its own > index in arranged objects. > > Does this seem like a sane approach? Honestly, not really. It does not sound like the number is a function of the model object. A better approach might be to either implement the -tableView:willDisplayCell:forTableColumn:row: or switch to using data source methods and implement –tableView:objectValueForTableColumn:row:. In either case you allow the table view to determine the line number, which seems more sensible to me. HTH, 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: Set up an editable view based NSTableView programmatically - how to?
On Jan 7, 2014, at 9:40 AM, Peter wrote: > > Am 07.01.2014 um 17:32 schrieb Jens Alfke : > >> >> On Jan 7, 2014, at 7:52 AM, Peter wrote: >> >>> I’d be very happy if somebody could point me to an example of an editable >>> NSTableView set up programmatically. >> >> It sounds like you just mean using a custom data source rather than relying >> on bindings to provide the data? That’s very easy to do. Just look at the >> docs for NSTableViewDataSource — you just need to implement the three >> methods to provide the row count, get a cell value, and set a cell value. >> >> —Jens > > Oops, sorry, the crucial info is only in the subject line: I meant a view > based NSTableView. Which as far as I could find out does not make use of the > NSTableViewDataSource protocol. I seems that you have to have to use delegate > methods to make it work. Umm, in the documentation for NSTableCellView it sats: objectValue The object that represents the cell data. @property(retain) id objectValue Discussion The objectValue is automatically set by the table when using bindings or is the object returned by the NSTableViewDataSource protocol method tableView:objectValueForTableColumn:row:. Not to mention that I have used view-based table views with data sources... 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
BT data (NSData *) question
I am receiving data from an RFduino board to my iOS application. In Arduino land it's being sent like so: RFduinoBLE.send(1); //button pressed RFduinoBLE.send(0); //button released In my didReceive:(NSData *)data I have this: const uint8_t *value = [data bytes]; I would like to evaluate that value in an if else statement. Right now someone wrote in that method: if( value[0]){ NSLog(@"pressed"); } else { NSLog(@"released"); } So I think this is simply looking for a 1 (true) or anything else (0). If I wanted to add support for another button, I'd send a different byte... RFduino.send(2); How can I adjust that if else statement properly to evaluate the data sent to the iOS application over BLE? I'm in unchartered territory here. Is it something like the below? I'm thinking no... if( value[0] == 1 ){ NSLog(@"button a pressed"); } else if( value[0] == 2){ NSLog(@"button b pressed"); } else { NSLog("button released"); } Thanks for your time and attention, Eric ___ 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: BT data (NSData *) question
On Jan 7, 2014, at 10:22 AM, Eric E. Dolecki wrote: > How can I adjust that if else statement properly to evaluate the data sent > to the iOS application over BLE? > > I'm in unchartered territory here. Is it something like the below? I'm > thinking no... The code you put below looks fine, though I’d go with a switch statement instead; it’s cleaner. No offense, but this looks really straightforward to me. What about it is confusing you? The if/else syntax? The byte value in the NSData? The button logic? —Jens ___ 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: BT data (NSData *) question
I wasn't sure about evaluating like that (value[0] = 2) or if I'd need to convert it to something first. I've never used uint8_t before. Google Voice: (508) 656-0622 Twitter: eric_dolecki XBoxLive: edolecki PSN: eric_dolecki On Tue, Jan 7, 2014 at 1:54 PM, Jens Alfke wrote: > > On Jan 7, 2014, at 10:22 AM, Eric E. Dolecki wrote: > > How can I adjust that if else statement properly to evaluate the data sent > to the iOS application over BLE? > > I'm in unchartered territory here. Is it something like the below? I'm > thinking no... > > > The code you put below looks fine, though I’d go with a switch statement > instead; it’s cleaner. > No offense, but this looks really straightforward to me. What about it is > confusing you? The if/else syntax? The byte value in the NSData? The button > logic? > > —Jens > ___ 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: BT data (NSData *) question
On Jan 7, 2014, at 12:00 PM, Eric E. Dolecki wrote: > I wasn't sure about evaluating like that (value[0] = 2) or if I'd need to > convert it to something first. I've never used uint8_t before. It’s just a typedef for ‘unsigned char’. Nothing magic. —Jens ___ 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: Set up an editable view based NSTableView programmatically - how to?
Thank you for your comment. Did you really manage to create *editable* view-based table views with data sources? Then I am curious to know how you managed to make them editable. A data source method channeling data from the table view to the data source is nowhere to be seen. - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row does not seem to be called. I have a view based table view working with a data source. But it is not (yet) editable. The only thing I can imagine is to catch textDidEndEditing in a delegate from the field editor and get the value via editedRow and editedColumn or something similar. But this is rather awkward. I wonder why there is nothing relevant in the docs, no example on the web... Am 07.01.2014 um 18:11 schrieb Keary Suska : > > On Jan 7, 2014, at 9:40 AM, Peter wrote: > >> >> Am 07.01.2014 um 17:32 schrieb Jens Alfke : >> >>> >>> On Jan 7, 2014, at 7:52 AM, Peter wrote: >>> I’d be very happy if somebody could point me to an example of an editable NSTableView set up programmatically. >>> >>> It sounds like you just mean using a custom data source rather than relying >>> on bindings to provide the data? That’s very easy to do. Just look at the >>> docs for NSTableViewDataSource — you just need to implement the three >>> methods to provide the row count, get a cell value, and set a cell value. >>> >>> —Jens >> >> Oops, sorry, the crucial info is only in the subject line: I meant a view >> based NSTableView. Which as far as I could find out does not make use of the >> NSTableViewDataSource protocol. I seems that you have to have to use >> delegate methods to make it work. > > Umm, in the documentation for NSTableCellView it sats: > > objectValue > > The object that represents the cell data. > > @property(retain) id objectValue > Discussion > > The objectValue is automatically set by the table when using bindings or is > the object returned by the NSTableViewDataSource protocol method > tableView:objectValueForTableColumn:row:. > > Not to mention that I have used view-based table views with data sources... > > 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: Set up an editable view based NSTableView programmatically - how to?
On Jan 7, 2014, at 1:38 PM, Peter wrote: > Thank you for your comment. > > Did you really manage to create *editable* view-based table views with data > sources? Yes. > Then I am curious to know how you managed to make them editable. The issue here is simply how to communicate edits to your model object, which I will assume you mean by "making editable". > A data source method channeling data from the table view to the data source > is nowhere to be seen. > > - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object > forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row > > does not seem to be called. No, you can't use this method with view-based table views. And it makes sense, as the table view wouldn't how how to apply edits to the model object since it could be arbitrarily complex. > I have a view based table view working with a data source. But it is not > (yet) editable. > > The only thing I can imagine is to catch textDidEndEditing in a delegate from > the field editor and get the value via editedRow and editedColumn or > something similar. > But this is rather awkward. > > I wonder why there is nothing relevant in the docs, no example on the web... Did you look at TableViewPlayGround sample code? It might have editable examples (I don't recall). There are a number of ways you can do this. My case is a bit specific and complex (every cell in in my table is different), but my basic approach was to designate a set of NSViewControllers that are set as the owners of the views in -tableView:viewForTableColumn:row: (as well as in IB), and in the view I have an NSObjectController bound to the view controller's representedObject, and the editable fields bound to it in turn. HTH, 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: Set up an editable view based NSTableView programmatically - how to?
Am 07.01.2014 um 23:16 schrieb Keary Suska : > On Jan 7, 2014, at 1:38 PM, Peter wrote: > >> Thank you for your comment. >> >> Did you really manage to create *editable* view-based table views with data >> sources? > > Yes. > >> Then I am curious to know how you managed to make them editable. > > The issue here is simply how to communicate edits to your model object, which > I will assume you mean by "making editable". > >> A data source method channeling data from the table view to the data source >> is nowhere to be seen. >> >> - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object >> forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row >> >> does not seem to be called. > > No, you can't use this method with view-based table views. And it makes > sense, as the table view wouldn't how how to apply edits to the model object > since it could be arbitrarily complex. > >> I have a view based table view working with a data source. But it is not >> (yet) editable. >> >> The only thing I can imagine is to catch textDidEndEditing in a delegate >> from the field editor and get the value via editedRow and editedColumn or >> something similar. >> But this is rather awkward. >> >> I wonder why there is nothing relevant in the docs, no example on the web... > > Did you look at TableViewPlayGround sample code? It might have editable > examples (I don't recall). Yes, I did, but no, sadly it doesn’t. > There are a number of ways you can do this. My case is a bit specific and > complex (every cell in in my table is different), but my basic approach was > to designate a set of NSViewControllers that are set as the owners of the > views in -tableView:viewForTableColumn:row: (as well as in IB), and in the > view I have an NSObjectController bound to the view controller's > representedObject, and the editable fields bound to it in turn. OK, thanks for the pointers. This confirms my suspicion that (a) there is no simple way to do it (as in cell based tables) and (b) that view based tables, despite some obvious advantages, are not to be considered to be the Holy Grail of Table Making - as Apple wants to make us believe. BTW: The delegate methods I had intended to use in my outline above turned all out to be disabled for view based table views. Thanks a lot for your time and comments! > HTH, > > 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: Set up an editable view based NSTableView programmatically - how to?
On Jan 7, 2014, at 14:27 , Peter wrote: > OK, thanks for the pointers. This confirms my suspicion that (a) there is no > simple way to do it (as in cell based tables) and (b) that view based tables, > despite some obvious advantages, are not to be considered to be the Holy > Grail of Table Making - as Apple wants to make us believe. So, how are the elements of your cell view getting their values? Bindings? If so, they’re (presumably) bound *to* or *via* the cell view’s “objectValue” property. Therefore, if the element is editable, when its value changes it’s going to invoke a setter on the bound data-model object. Therefore, that object needs to *have* a setter. That setter should be invoked at the value change without your having to do anything. If bindings aren’t connecting view elements all the way to data model properties, then you’ll a little extra code to write — either to provide the “missing” KVO compliant mutable properties, or to “intercept” the values being set. This may involve adding properties/behavior to your “objectValue” objects, or possibly subclassing NSTableCellView. I can’t give you a more specific answer than than, because the details will depend on exactly what you are modify, but does that generic explanation throw any light on your problem? > BTW: The delegate methods I had intended to use in my outline above turned > all out to be disabled for view based table views. I recommend you go directly to the NSTableView.h header file comments for definitive statements about what is called for what kind of views. The information is scattered throughout the file, so it’s difficult to read, but that’s the definitive and correct source for this information. ___ 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: Set up an editable view based NSTableView programmatically - how to?
Op 7 jan 2014, om 16:52 heeft Peter het volgende geschreven: > I’d actually prefer to use bindings, but my first column should simply > display the row numbers After some experimenting I managed to create a simple editable view based table view with row numbers, using bindings except for the row number. The row number is in a column with identifier "RowNumber". I implemented this delegate method: - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSTableCellView *result = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:self]; if ([[tableColumn identifier] isEqualToString:@"RowNumber"]) result.textField.objectValue = [NSNumber numberWithInteger:row]; return result; } That's all. This is the first time I used a view based table view and it looks too simple but maybe it helps. Willeke ___ 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: Set up an editable view based NSTableView programmatically - how to?
Great! Yes, this helps immensely. Thank you very much! It didn’t occur to me that it is possible to mix the bindings and data source approaches. In order not to waste more time and get my job done, I took resort to a double click method copying the data to be edited to an NSTextField, whose action methods feeds the edited value back into the data source. Works very nicely and fits my bill even better than inline editing. Still, your proof of concept is extremely useful! Am 08.01.2014 um 01:01 schrieb Willeke : > > Op 7 jan 2014, om 16:52 heeft Peter het volgende geschreven: > >> I’d actually prefer to use bindings, but my first column should simply >> display the row numbers > > After some experimenting I managed to create a simple editable view based > table view with row numbers, using bindings except for the row number. The > row number is in a column with identifier "RowNumber". I implemented this > delegate method: > > - (NSView *)tableView:(NSTableView *)tableView > viewForTableColumn:(NSTableColumn *)tableColumn > row:(NSInteger)row > { > NSTableCellView *result = [tableView > makeViewWithIdentifier:[tableColumn identifier] owner:self]; > if ([[tableColumn identifier] isEqualToString:@"RowNumber"]) > result.textField.objectValue = [NSNumber numberWithInteger:row]; > return result; > } > > That's all. > This is the first time I used a view based table view and it looks too simple > but maybe it helps. > > Willeke > ___ > > 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/magnard%40web.de > > This email sent to magn...@web.de ___ 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: Set up an editable view based NSTableView programmatically - how to?
To clarify: this isn't mixing approaches. Willeke isn't using any datasource methods at all. tableView:viewForTableColumn:row: is a delegate method. The *only* datasource method view-based table views support is the objectValue getter, which simply sets the objectValue property on the view returned by the delegate method, if that view has one. That's it. It's the same as assigning tableCellView.objectValue in that delegate method yourself. -- Seth Willits On Jan 7, 2014, at 4:17 PM, Peter wrote: > Great! Yes, this helps immensely. Thank you very much! > > It didn’t occur to me that it is possible to mix the bindings and data source > approaches. > > In order not to waste more time and get my job done, I took resort to a > double click method copying the data to be edited to an NSTextField, whose > action methods feeds the edited value back into the data source. Works very > nicely and fits my bill even better than inline editing. > > Still, your proof of concept is extremely useful! > > Am 08.01.2014 um 01:01 schrieb Willeke : > >> >> Op 7 jan 2014, om 16:52 heeft Peter het volgende geschreven: >> >>> I’d actually prefer to use bindings, but my first column should simply >>> display the row numbers >> >> After some experimenting I managed to create a simple editable view based >> table view with row numbers, using bindings except for the row number. The >> row number is in a column with identifier "RowNumber". I implemented this >> delegate method: >> >> - (NSView *)tableView:(NSTableView *)tableView >> viewForTableColumn:(NSTableColumn *)tableColumn >> row:(NSInteger)row >> { >> NSTableCellView *result = [tableView >> makeViewWithIdentifier:[tableColumn identifier] owner:self]; >> if ([[tableColumn identifier] isEqualToString:@"RowNumber"]) >> result.textField.objectValue = [NSNumber numberWithInteger:row]; >> return result; >> } ___ 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
NSScrollView problem
Folks, I'm using Xcode 5.0.2 with OSX10.8.5. When I build a simple OS Application (nonDocument type) and I move an NSScrollView onto a window and then run the program, it builds normally, but it flags a problem that there is a "Misplaced View" and that "Frame for 'Clip View' will be different at run time. The view hierarchy is: Window -> View -> BorderedScrollView -> ClipView -> PlotView -> and 2 Scrollers. I've called the final view PlotView because it's contents would seems to be the part you would see on screen. If I attach a simple label to the PlotView, it does not appear at run time. Further, nothing I try to draw on PlotView appears. The documentation on scrollers makes perfect sense, but this process doesn't work as expected. I have also tried the following: Build a document based OS Application, add an NSWindowController class with it's .xib file, add an NSView class (usually called PlotView), add an NSScrollerView to the window in the .xib file. Identify the plot view with the PlotView class and name the File Owner of the .xib file the WindowController, tie everything together, and then try to get the PlotView class to draw something on the screen. But no luck whatsoever! My primary experience 'til now was with Xcode 3.2.4 where all this worked like a charm. So I guess my question is, "what has changed, and what must I do additionally to draw in a scrolled view"? Thanks in advance, 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
Help to debug NSPerformService..
OS X 10.8.5, Xcode 5.0.2, Document app In my app I have this: @interface Guess : NSTextField // populated programmatically … -(void)check; // method to programatically use the Service "Look Up In Dictionary" @end @implementation Guess ... -(void)check { // Lookup word in dictionary [self selectText:nil]; NSString *theString = [self stringValue];// debug shows ( _NSCFString*) @"THERE" NSArray *toLookup = [NSArray arrayWithObjects:theString,nil]; // debug shows (_NSArray *) @"1 object" NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; // debug shows (NSPasteboard *) 0x10011a7b0 NSInteger changeCount = [pasteboard clearContents]; // debug shows (NSInteger) 9 BOOL OK = [pasteboard writeObjects:toLookup]; // debug shows (BOOL) YES // ** This is my problem BOOL res = NSPerformService(@"Look Up In Dictionary", pasteboard); // debug shows (BOOL) NO } ... @end If I manually select the text in the field by double clicking it, the Services menu is populated and does contain "Look Up In Dictionary". The Services Implementation Guide in the section on Using Services has a section on Validating Services Menu Items. There is some sample code but I do not understand how to apply this for my very simple case. I looked in the TextEdit code but did not find anything helpful. Please explain what I should do to programatically accomplish this simple "Look Up In Dictionary" task. Thanks for your help. respect… Peter ___ 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: NSScrollView problem
On Jan 7, 2014, at 17:14 , James Pengra wrote: > I'm using Xcode 5.0.2 with OSX10.8.5. When I build a simple OS > Application (nonDocument type) and I move an NSScrollView onto a window and > then run the program, it builds normally, but it flags a problem that there > is a "Misplaced View" and that "Frame for 'Clip View' will be different at > run time. The view hierarchy is: Window -> View -> BorderedScrollView -> > ClipView -> PlotView -> and 2 Scrollers. I've called the final view PlotView > because it's contents would seems to be the part you would see on screen. If > I attach a simple label to the PlotView, it does not appear at run time. > Further, nothing I try to draw on PlotView appears. You don’t have a scroll view problem, you have an auto layout problem in your XIB file. Based on the above information, there are probably 2 things going on: 1. You mis-positioned a view relative to its default constraints. That leads to the “frame will be different at run time” message. Use Editor -> Resolve Autolayout Issues to have it fix the frame or the constraints. 2. You don’t have useful or meaning constraints on the label subview, so it’s positioned somewhere outside the visible part of the PlotView. Or it got resized to zero, so there’s nothing to see even if it’s in the right place. ___ 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: Help to debug NSPerformService..
On Jan 7, 2014, at 9:57 PM, Peter Teeson wrote: > OS X 10.8.5, Xcode 5.0.2, Document app > > In my app I have this: > @interface Guess : NSTextField // populated programmatically > … > -(void)check; // method to programatically use the Service "Look Up In > Dictionary" > @end > > @implementation Guess > ... > -(void)check { // Lookup word in dictionary >[self selectText:nil]; >NSString *theString = [self stringValue];// debug shows ( > _NSCFString*) @"THERE" >NSArray *toLookup = [NSArray arrayWithObjects:theString,nil]; // debug > shows (_NSArray *) @"1 object" >NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; // debug > shows (NSPasteboard *) 0x10011a7b0 >NSInteger changeCount = [pasteboard clearContents]; // debug shows > (NSInteger) 9 >BOOL OK = [pasteboard writeObjects:toLookup]; // debug shows (BOOL) YES > > // ** This is my problem >BOOL res = NSPerformService(@"Look Up In Dictionary", pasteboard); // > debug shows (BOOL) NO > } > ... > @end > > If I manually select the text in the field by double clicking it, the > Services menu is populated and does contain > "Look Up In Dictionary". The slight bit of example code from Apple showing a use of NSPerformService() uses +pasteboardWithUniqueName, not + generalPasteboard. You could try that. https://developer.apple.com/library/mac/samplecode/PhotoSearch/Listings/MainWindowController_m.html Also, you can try launching your app with "-NSDebugServices com.apple.Dictionary" to see if that's informative. That said, perhaps you're actually looking for the -[NSView showDefinitionForAttributedString:…] methods. 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