I have a ruby class and a match definition in core data.
There is a NSData field 'image_data' to store my image.
In my ruby class, i was thinking to add a getter to return an UIImage.
However, i get an error saying "undefined method `image' for #"
What do i need to do to get around this?
class ActivityImage < NSManagedObject
def image
UIImage.imageWithData(image_data)
end
end
I think what you're looking for is a way of creating a "Transformable Attribute".
If you read through that guide, you'll get to understand what transformable attributes are, hopefully you're using Xcode's model editor so you can just create the attribute in there, but otherwise you'll just have to pull some hackery to get the entity then create the image attribute and set it as transformable.
Related
In an EA model I have a class. The class defines an attribute. I want to be able to have an instance of this class (an object) with the attribute visible on a diagram and the ability to link specifically to that attribute (as in the Link to Element Feature option).
Is it possible?
Yes and no. You need to set the run state of the object
Once the following dialog is completed, it can look like
The value is free text and not linked to the original attribute, but better than nothing.
I'm attempting to create view/viewModel pair to act as a MessageBox replacement which will be called by the UIVisualizer Service. The viewModel has five different constructors, one being the default, and the others to define the different attributes of the MessageBox(e.g. Type, Image, Message, Title, etc.). I will be creating the viewModel using one of the four non-Default constructors each time I desire a MessageBox to popup. I am doing this versus using the built-in MessageService is because I'm using third party controls for my application and I want the MessageBox look-and-feel to match the rest of the application.
My problem is that even though I'm creating the viewModel, Catel is not using the viewModel I pass in to UIVisualizer, but is creating a new viewModel from the default constructor.
Does anybody know how to get this behavior to stop.
The best thing to do is create your own version of the IMessageService (create new class deriving from MessageService and override the Show method).
Catel should re-use the passed in view model. If you think you have found a bug, please report it at http://www.catelproject.com/support/issue-tracker
I have a RPC method that returns a List of Strings. I want to create a ComboBox with a store that will load the values through a RpcProxy, but I can't find an example that doesn't use some sort of ModelData class.
I would prefer not to have to create a simple Bean with only one property (the string) and then have to convert the List one item at a time.
My ideal would be to create something like this:
RpcProxy<List<String>> proxy = new RpcProxy<List<String>>()...
Any suggestions?
Unfortunately, with GXT 2.2.5, you can't get around not using ModelData.
The class definition for ComboBox says it all:
public class ComboBox<D extends ModelData> extends TriggerField<D> implements SelectionProvider<D> {
...
protected ListStore<D> store;
...
So, at this point your biggest concern is keeping your code clean. If you have to make a specialized ModelData derived class, you could subclass ComboBox and keep a nested class definition for your wrapper object.
If you're not tied to using GXT 2.2.5, I would update to GXT 3.0.x and GWT 2.5.0. GXT 3 moved away from using ModelData. Now, everything accepts bean-like objects.
I have an iPad app, using Storyboards, XCode 4.5 and iOS 6. I am trying to get started using MagicalRecord. I have everything installed and it builds correctly. I have created an empty entity called ClientInfo with attributes. I have also generated the NSManagedObject (Editor > Create NSManagedObject Subclass… > Create) but don't know what to do with it either.
This is the instruction that is my "brick wall"; I am unable to follow the following instruction:
import the NSManagedObject subclass of the entity you want to save
into you’re class
I have looked at examples, Googled it and looked at SO. I can't find a good example from starty to finish. Anybody know of a real good doc or example on MagicalRecord? Or, show me a real simple example that explains this where the MagicalRecord does not?
In Xcode, select the entities in the Core Data model editor and choose "Editor -> Create NSManagedObject Subclass ..." from the menu. This creates .h and .m for each entity, e.g. ClientInfo.h and ClientInfo.m.
Import the NSManagedObject subclass in your class file, e.g. #import "ClientInfo.h".
Note that you have to redo step 1 after modifiying the entities.
The NSManagedObject subclasses declare all the properties and methods for you entity, so you can (for example) write
clientInfo.name = #"foo";
instead of
[clientInfo setValue:#"foo" forKey:#"name"];
I need to sort I need to subclass NSDate to add a tag, I don't need to change its behaviour, do I still need to implement my own:
(NSTimeInterval)timeIntervalSinceReferenceDate
(id)initWithTimeIntervalSinceReferenceDate:(NSTimeInterval)seconds;
as stated in apple's documentation? If so, how do I do it?
currently I just created a class extends NSDate with a tag attribute, but how do I initialise it?
Thanks!
NSDate is a class cluster, not a simple class. It is not wise to subclass a class cluster unless you know exactly what you are doing; see How do I subclass NSDate?
I would recommend that you create your own class containing an NSDate and a tag, and extend as needed:
#interface MyClass : NSObject {
NSDate *_date;
NSUInteger _tag;
}
#end
Add the appropriate properties, etc for easy dot-notation access.