I'm fairly new to Core Data, so I'm sure there's a simple answer to my question, but here goes. I have an NSStepper, NSLevelIndicator, and an NSTableView with a column containing an NSImageCell. When the "priority" is changed through the slider or level indicator, I want to update the other control, update the model, and change to a custom image in the table view. Obviously, I only want to update the row where the priority was changed. My first thought was this, but the last two sections of code have me stumped. Updating the controls works fine, but when it comes to updating the model and setting the image, I'm not sure what to do. There are 4 priorities: 0, 1, 2, and 3, and in the resources folder are 4 images: priority0.tiff, priority1.tiff, priority2.tiff, and priority3.tiff. I realize that I am trying to set the image to the wrong view, I'm just not sure which one to use. Also, I know things would be much easier with bindings, but I'm not sure which to set. Lastly, since I wasn't sure which bindings to use, I wanted to programmatically update the model, by updating the array controller corresponding the entity I was using. The attribute for the entity is priority. I'm not sure what to do here, either. Also, the last line tells me that arguments 1 and 2 of setValue:forKey: make a pointer from and integer without a cast. How do we make a cast in objective-c?

Miscellaneous:
- Is there a simple way to programmatically create a blank NSImage ?

To sum up:
- What view to set, so that only the right row is updated with the appropriate image?
- What bindings should be used, and what code would they replace?
- How do I programmatically update the right attribute of the right entity of the model?
- How do I use bindings to do this?
- How do I typecast in objective-c?
- How do I create a blank NSImage?

- (IBAction)setPriority:(id)sender
{       
// Check to see which control modified priority and set other view to new value...
        int priority;
if ([[NSString stringWithFormat:@"%@", [sender class]] isEqual:@"NSStepper"]) {
                priority = [priorityStepper intValue];
                [priorityLevelIndicator setIntValue:priority];
        }
else if ([[NSString stringWithFormat:@"%@", [sender class]] isEqual:@"NSLevelIndicator"]) {
                priority = [priorityLevelIndicator intValue];
                [priorityStepper setIntValue:priority];
        }

        // ... update priority image cell.
[priorityCell setImage:[NSImage imageNamed:[NSString stringWithFormat:@"priority%i", priority]]];
        
        // ... and update model.
        [[iItemController selectedObjects] setValue:priority forKey:priority];
}

Thanks for the help, and I apologize for all the questions.

- Walker Argendeli

_______________________________________________

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

Reply via email to