Attribute called 'description' causes crash - objective-c

I just started playing with Core Data.
I created an entity called Task with a property called Description. I opened Interface Builder and I added Core Data Entity view.
Picked my entity, property and tried to build the application. After clicking on "Add" button it crashed with EXC_BAD_ACCESS.
After I've renamed this attribute to 'desc' it works fine.
Can anyone explain me why is this happening? Is 'description' some kind of reserved word in Core Data or something?

description is ann Objective-C property used for debugging and goes all the way down to Core Foundation, which has a corresponding CFDescription function. You should just name that property something else.

It's a method with a particular purpose in Cocoa, and Core Data dislikes it being overridden. More here.

Related

How to use a custom icon in a dolphin smalltalk treeview?

In a Dolphin smalltalk treeview I'd like to use a custom icon, depending on the state of the item displayed, (differente state, different icon)
How can I do that ?
I cannot really understand how to use a "my" icon.
I've create a class "connection", with an instance variable "connected"
and two class methods "connectedIcon and unconnectedIcon that returns icon images.
Then an instance function "icon" that returns one or the other image based on the connection state.
I can add instances of this class to a tree view and see the name of the connections.
But how to show my Icons ?
I tried to sustitute the getImageBlock of my presenter view with the following expression [:obj | obj icon] but it doesn't work.
(nothing seems to happen).
this is made in my presenter initialize :
initialize
super initialize.
treePresenter view getImageBlock: [:obj | obj icon]
what's wrong with it ?
best regards
Maurizio
When you are editing a TreeView, one of the properties is getImageBlock. By default it is not really a block but another object that understands the message #'value:' (the class IconicListAbstract). You can replace this property with a code block (or other object that understands #'value:') and answer the image you want displayed.
In Microsoft Windows, icons are typically stored in a DLL. You should be able to use an icon explorer or editing tool to see the icons in a dll. For example, get IconExplorer from http://www.mitec.cz/iconex.html and try opening DolphinDR7.dll. Do the icons and numbers match what you see when you return a number in your application?
To determine (or override) the resource library used, see SessionManager>>#'defaultResLibPath'.
Typically, the getImageBlock is set using the property editor in the GUI editor, but setting it through code can work as well.
Wonderful Dolphin Smalltalk!
I had two problems
1) how and where to modify the getImageBlock method of my Treepresenter.
2) where to put the icons ad how to get the imageindex of each icon.
This is the solution :
1) it's not needed.
The treeview sends an #iconImageIndex" message to my model
this is handled by the default method (in the Object class) that send to my object the message #icon
and to the result of this message (an icon) the message #iconIndex.
This message is understood from the icon that answers with its own iconIndex.
So the only method I need to impement is #icon in my class Connection
that I implemented as follows:
icon
opened ifTrue: [^Connection connectedIcon] ifFalse: [^Connection unconnectedIcon]
In the class itself the two icons are imported in the image by evaluating the createIconMethod,
as explained in the blog article 'Beauty with less Beast'.
So my problems are solved.
Thanks to all.
Maurizio.

How to decorate Objective C methods with documentation?

When I'm typing up a Cocoa object and calling a selector on that object, I sometimes can see 'documentation' or 'help' information about that method. For instance, as I type [NSArray alloc], I see two help hints. One for NSArray, and one for alloc. Both of these appear in the popup autocomplete suggestions listbox as I type the code.
How do I produce similar method/class decorated help hints which will appear when I type? I want to see my comments as I type my custom class name and custom methods. How can I do this?
For instance, C# provides this feature through XML documentation which can be placed before any method, class, or interface/protocol declaration.
You have to create a “docset”. There are tools like appledoc for creating docsets from your comments. You could set up a build phase that runs appledoc on your code.
The problem is that there's no way to make Xcode 4 reload a docset except by restarting Xcode. So even if you run appledoc automatically as part of your build, you will have to restart Xcode to make it see the changes to your docset.

Titanium Properties API usage

I'm new to Titanium Properties API. I'm getting a weird error when using setObject() method.
Following is my code.
Titanium.App.Properties.setObject(view.idAttr, view);
Where view.idAttr is a string acting as a key for this property and view is a View type object. Upon calling above method, I get following message.
2012-09-14 17:47:25.947 SumMeUp[14033:4a03] *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '[object TiUIView]' of class 'TiUIViewProxy'. Note that dictionaries and arrays in property lists must also contain only property values.
I couldn't understand this behavior. If anyone knows a solution to, please reply.
Thanx
setObject() is meant for objects only, not for views.
A object would be something you write yourself in JavaScript.
Even if it could, it would be bad behaviour of the app to store it in a property. Remember the property is being stored cross-session. So if you want something stored, store data there to generate the view later again, not the view itself. Also saves a lot of memory!

XCode 4 Generating classes from entities in CoreData

Im using XCode 4 and working with CoreData. Now, how do I generate classes for entities? I used to do it in XCode 3 by clicking on a diagram entity, going to File->New and choosing NSManagedObject class.
For some reason i cant seem to find it in XCode 4, it's not showing up in the dialog...
If you are new to Xcode (like me) some graphics to make it easier to explain. Just make sure that you select the entities that you want before you click on "Create NSManagedObject Subclasss"
You'll find in DP5 it is now a menu item. Finally!
I got it working by making the entity CLASS the same as the entity NAME, i.e. "Person" instead of "NSManagedObject". I also noticed that I have to invoke File > New File twice (!) The first time, the Managed Object Class template is not available, but the second time it is. No clue why.
I'm running XCode 3.2.4.
While editing your xcdatamodel you need to select the entity and make sure the right hand Utilities pane is open. Select the Data Model Inspector (the tab on the right) and you can set the class of your entity to whatever you want.

Core Data and UI Binding

My application builds its user interface and a core data model through code (no .xib .nib or .xcdatamodel files).
I'm having trouble finding documentation on how to bind core data entity attributes (in an NSManagedObject) with the object properties of a UIView or UIViewControler such that the two are kept synchronized with each other.
I could simply write code to move data between Core Data and the UI, then trap all events for field changes, but there are hints everywhere that this can be handled automatically using Key-Value mapping somehow.
Can anyone point me in the right direction or show me some sample code on how this binding is achieved through code?
Much appreciated.
Chris.
Bindings are not available on iOS. Instead there is the NSFetchedResultController.