How to create a user interface from an object in Xcode 4?

I experimented with basic data for several days and spent the last couple of hours trying to figure out how to create a user interface from an object in xcode 4. According to the books I read, you will have to drag the main data object into the window in the interface builder, but when I do this is in xcode 4, nothing happens. The apple documentation did not help as it was not updated for xcode 4. I am sure this is really obvious, but I just can not understand.

+5
source share
1 answer

Your question is perfect for me, as I recently started studying Mac / Cocoa development and ran into the same problem.

After looking at the documentation, searching on Google, checking all the Xcode menu and game parameters using all possible keyboard and mouse combinations, I might have thought that it was impossible to call the wizard to create your interface from your objects in Xcode 4.

This answers your question, but leaves you with the same problem as me - Where are you now?

This is what I did to get my application working (note that this is also explained in the videos related to Eric Aigner):

  • Drag the new NSArrayController into your NIB file. Open the attribute inspector and change the mode to "Entity" and change the "Object Name" field to the name of your entity (face EG).
  • Create your interface as usual by dragging items into your window.
  • For each control that you want to bind to your entity, do the following: Select a control, open the binding inspector and bind the value to the array controller. The controller key field must be set as "selection", and the model key path must be bound to the field of the object you want to bind to (EG "name").

Obviously this only applies to a very basic scenario, but it should be enough for you to start (if you are reading the same book as me, then be prepared for everything to tear again in the next chapter when you try to bind to related objects!).

There are several more gaps in my knowledge, since I studied Core Data for 2 days (and Cocoa / Objective-C for less than a week), so if any of the above information is incorrect, Cocoa experts should let me know, and I accordingly I will update my message.

+5
source

Source: https://habr.com/ru/post/892879/


All Articles