Importing Object from other class - iphone

I want to import an object from other class to one class.
I followed the method of #import "xyz.h" in abc class implementation.
Any tried to add the object of xyz class in one method of abc class.
But it shows an error :
Property 'a' not found on object of type xyz.
Can any one let me know how to import the object ?

Is the property defined in the header xyz.h, or elsewhere (such as in the class extension or another category)? It'll need to be in the header if you need to use the property from another object (or, if it's in a category, you need to declare the category in a header that you can import).

Related

How to print the object name (not class) in Swift?

From this answer, I know that I can get the name of the class type using
NSStringFromClass(YourClassName)
But I actually also need the name of the current object instance. So if I have code like this:
let loginForm = LoginFormViewController();
I want to actually get the loginForm in string, within the implementation of LoginFormViewController.
How can I do that?

How can I load a matlab object of which the class definition file was placed in separate package

Is it possible in matlab to load an object of which the class definition file was placed in separate package?
For example:
T = myTestClass;
save('T');
Now I want to place my class in a package, so I create the directory structure as follows:
+myTestPack/#myTestClass/myTestClass.m
Next I try to recover the saved object:
import myTestPack.*
load('T.mat');
The outcome is always:
Warning: Variable 'T' originally saved as a myTestClass cannot be instantiated as an object and will be read in as a uint32.
Is there any way to solve this problem? I would like to restructure my code but a lot of old data was saved as objects.
Maybe I need to add loadobj/saveobj methods to the definition file or maybe there is a way to rename the class from myTestClass to myTestPack.myTestClass?
Thank you for your suggestions!
You need to add loadobj method to your new class. You also need a simple class myTestClass in the old location with just a loadobj method which calls loadobj method of the moved class. MATLAB does not know that you have moved the class. When loading all it knows is that it is of class type myTestClass and tries to create one by looking up myTestClass.

Swift Core Data: auto-generating managed object subclass makes the class name to PRODUCT_MODULE_NAME.entityName in model

I'm making a purely Swift project, and when I create an entity in model file, then use Editor->Create NSManagedObject Subclass to create class file for the entity, in the model, the Class property for entity becomes PRODUCT_MODULE_NAME.entityName, this will cause core data to fail loading NSManagedObject subclass instance.
I know how to get pass by this by using #objc() and rename the class property in model file, but is there any better idea?
Two options:
Replace the PRODUCT_MODULE_NAME with the value of this build setting. By default, it will be the same as your TARGET_NAME. The full value in the Class field should be something like MyApp.entityName.
Use only entityName in the Class field and prefix your swift class with #objc(entityName)
The representedClassName field in the data model appears to be evaluated at runtime so it needs a literal value.

Get the class structure instance of a GObject type

How do I get a class object of a certain class in GObject / Gtk? For example, if my class is GtkSpinButton, I want to get the instance of GtkSpinButtonClass that represents the class. It is the parameter "class" in
gtk_spin_button_class_init (GtkSpinButtonClass *class)
and it is the object where virtual functions are stored. When I have an instance of GtkSpinButton, I can call
GtkSpinButtonClass *class = GTK_SPIN_BUTTON_GET_CLASS (instance)
however I don't have an instance around. GTK_TYPE_SPIN_BUTTON gives me the type id, a number, and not the class object. Any idea how to get the actual instance?
You want to use g_type_class_ref
GtkSpinButtonClass *klass = g_type_class_ref(GTK_TYPE_SPIN_BUTTON);
and when you're done with it
g_type_class_unref(klass);

What is #interface UITableView (MyTableViewDelegate)

Im looking at some source code written by someone else and its intrigues me to see this line:
#interface UITableView (MyTableViewGestureDelegate)
Now I have previously seen only this:
#interface MyTableView : UITableView <MyTableViewGestureDelegate>
so I am a lil confused.
Any ideas as what to what im looking at?
Ben
It is class category declaration - using categories you can split your class implementation into several files or add methods to existing classes.
It is a category declaration.
A category allows you to add methods to an existing class—even to one
for which you do not have the source. Categories are a powerful
feature that allows you to extend the functionality of existing
classes without subclassing. Using categories, you can also distribute
the implementation of your own classes among several files. Class
extensions are similar, but allow additional required APIs to be
declared for a class in locations other than within the primary class
#interface block.
The declaration of a category interface looks very much like a class interface declaration—except the category name is listed within parentheses after the class name and the superclass isn’t mentioned. Unless its methods don’t access any instance variables of the class, the category must import the interface file for the class it extends:
General Syntax:
#import "ClassName.h"
#interface ClassName ( CategoryName )
// method declarations
#end
Note that a category can’t declare additional instance variables for the class; it includes only methods. However, all instance variables within the scope of the class are also within the scope of the category. That includes all instance variables declared by the class, even ones declared #private.
There’s no limit to the number of categories that you can add to a class, but each category name must be different, and each should declare and define a different set of methods.
Please check the link and Example
MyTableView : UITableView < MyTableViewGestureDelegate > says your class MyTableView - subclass of UITableView - implements the protocol named MyTableViewGestureDelegate
UITableView (MyTableViewGestureDelegate) says you are creating a Category for the Class UITableView named MyTableViewGestureDelegate