I am updating and squashing bugs on a MacOS app I wrote several years ago. I have a subclass of NSTableView that I defined a delegate for that provides some convenience features for detecting user key and mouse input. The header file looks like this:
@class TKTableView;
// delegate protocol
@protocol TKTableViewDelegate NSObject,NSTableViewDelegate // NSObject because we need to use "respondsToSelector"
@optional(void)tableView:(NSTableView *)theTableView enterKeyPressedForRow:(NSInteger)theRow;
(void)tableView:(NSTableView *)theTableView deleteKeyPressedForRow:(NSInteger)theRow;
(void)tableView:(NSTableView *)theTableView didDoubleClickRow:(NSInteger)theRow;
(NSMenu *)tableView:(NSTableView *)theTableView showContextualMenu:(NSEvent *)theEvent;
@end
@interface TKTableView : NSTableView
@property(nonatomic,assign) NSUInteger myRowHighlightStyle;
@property(nonatomic,readonly) idTKTableViewDelegate delegate;
(void)doubleClickedRow:(id)sender;
@end
I'm getting warnings for...
@property(nonatomic,readonly) idTKTableViewDelegate delegate;
Warning 1: 'atomic' attribute on property 'delegate' does not match the property inherited from 'NSTableView'
Warning 2: Attribute 'readonly' of property 'delegate' restricts attribute 'readwrite' of property inherited from 'NSTableView'
I cobbled the delegate id property together via Google back when and cannot remember why I coded it as such. I know I can change to readwrite and atomic but I'm just not sure why it worked without warning in the past. What is the proper way to do this?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a subclass of NSTreeController where I've added a method for adding an object at a particular index path based on the current selection in an outline view. It's worked fine for almost a decade on every version of MacOS inbetween then and now. However a new client who just started using the app found a bug that I cannot for the life of me reproduce. She is using MacOS 11.4 and on a 2020 iMac i7. I'm on 11.5.2 and cannot get the same result with the exact same dataset.
When the user clicks the "Add Group" button in the window the IBAction below runs. It should...
Create a new object
Insert the new object directly below the current selection or at the top if nothing is selected
Select the new row and enter editing mode
The client is experiencing an error where the action doesn't insert anything but just selects the expected tree item and enters editing. I've posted a video she took for reference at (sorry the forum doesn't allow me to link or upload)
https://youtu.be/pV9-PjUsQrE
-(IBAction)addGroup:(id)sender
{
NSIndexPath *theIndexPath = [self selectionIndexPath];
id theObject = [[self objectClass] new];
[theObject setMyType:@"group"];
NSTreeNode *theTreeNode = [NSTreeNode treeNodeWithRepresentedObject:theObject];
if (!theIndexPath) // nothing is selected - maybe the array is empty
{
theIndexPath = [NSIndexPath indexPathWithIndex:0];
}
else
{
theIndexPath = [NSIndexPath indexPathWithIndex:[theIndexPath indexAtPosition:0]+1];
}
[self insertObject:theTreeNode atArrangedObjectIndexPath:theIndexPath];
[[self myOutlineView] editColumn:0 row:[[self myOutlineView] selectedRow] withEvent:nil select:YES];
}
It seems like insertObject: atArrangedObjectIndexPath: is failing. The odd thing is you can see that she was able to insert several items successfully prior to this error occurring. Further, the tree objects are in a MySQL database and I can connect to using the same app version she is using and I have no issues. Why would this be happening?
I have a title bar accessory view with an NSButton that has a color image showing the status of the window's main object. When the window is NOT key the title bar dims and along with it the image loses color and just shows as gray. I need the image to retain its color when not key so users can reference it when other windows are key. What are my options?
I have an older MacOS app that uses cell based tableviews. I am in the process of converting them to view based but hit a snag. When a cell based table ends editing the table view is sent as the object of the notification but when a view based table its the text field.
My code currently checks which table view is sending the notification and updates needed objects. If I switch to view based tables it looks like I'll have to assign tags to each cell view in order to identify it. Is there any way to get the table view for the textfield that ended editing?
Here's what my current code looks like...
-(void)controlTextDidEndEditing:(NSNotification *)aNotification
{
NSControl *theControl = [aNotification object];
if (theControl == [self myColorTableView])
{
[[[[self myColorArrayController] selectedObjects] objectAtIndex:0] updateMe];
}
}
I've got a MacOS app that has a pop up button whose content and values are bound to an array via an array controller. It works great when the array has objects in it. However, sometimes the bound array is empty and in these instances, the pop up button shows the description of a newly initialized object – not an actual object property value but the description with class name and property names and values – right in the popup menu.
The binding panel for the array controller looks like this...
I've tried turning off "Prepares Content" for the array controller and disabled the bound filter predicate but nothing is working. The pop up button is bound like...
I have an XCode project for a Mac App that's many years old. Recently, I decided to create a new XCode project and reimported all of the classes and assets to start fresh after constantly battling various compile errors. This worked great and I'm able to build and run without any of the previous issues.
The one problem I have is linking my private framework. In Build Phases I added my framework to Link Binary With Libraries and to Copy Files. I also added the path to my framework in Build Settings > Search Paths > Framework Search Paths. This works but whereas in the previous project when I make a change to my framework project and build it, I can then switch to my app project and XCode recognizes my new method(s) etc. In my new project this is not the case, I am getting editor error - "No visible @interface 'ClassName' declares the selector..."
I can change existing framework functions and see the results when I run my app so it's just the headers that are not updating. I added the path to my framework header in Build Settings > Search Paths > Header Search Paths and Build Settings > Search Paths > User Header Search Paths but they make no difference. Possibly I set the wrong path?
I can see that XCode created a Frameworks directory in my project folder when I added the framework in Build Phases but I can see the mod dates of the headers in that dir are not changing when I update a framework header and build it. What am I missing?
I have a macOS app that has a lot of form type inputs throughout. As such I have subclassed NSPopUpButton and implemented canBecomeKeyView to return YES. This works great as users can tab through fields and pop up menus to enter data. The issue is that when tabbing to a pop up I expect the user to see instant changes as they type, instead it takes 1-2 seconds before the menu changes. If the user hits the down arrow key it expands the menu and then type selection is instantaneous.
Is there any way to make NSPopUpButton respond instantly to typing, like a select menu in a web form? As it is it inhibits fast data input as you wait for it to recognize your input before tabbing to the next field.
I've got a macOS app that has a collection view all done with bindings and no datasource implementation. I've got it so I can drag and drop items, highlight selection and delete items. The last item is to bind the collection view selection to my array controller.
In IB I select the collection view then in the bindings inspector I select the array controller under selection indexes and enter the controller key of selectionIndexes. But this does nothing. If I log the collection view selectionIndexes it shows correctly but the array controller will show nothing.
I've fussed with this the entire day and am starting to believe it just won't work like it does with a table view. I thought about updating the array controller selection through the collection view delegate selection methods -didSelectItemsAtIndexPaths / didDeselectItemsAtIndexPaths but it feels like I must be missing something. Should this be possible and if not what are my alternatives?