I'm having a problem with what should be a very simple thing. I want to create an NSArrayController and specify the class it manages. Problem is, I can't figure out the correct way to specify the Class in the setObjectClass method. I want to do the following:
[projectArrayController setObjectClass:SKHProject];
SKHProject is a class that I've imported in the implementation file. I keep getting the "Expected expression before 'SKHProject'" error, but I can't figure out the correct expression. Where am I going wrong?
Do
[projectArrayController setObjectClass:[SKHProject class]];
!
Just found it
[projectArrayController setObjectClass:[SKHProject class]];
Thanks anyway
You can only use a class name as the receiver of a message; you can't use it in any other context. So, to pass the Class somewhere, send it a message asking it for itself: [SKHProjectClass class].
Related
Is there a way to check if a Class with a certain name exists in Parse?
In my db I am creating classes on the fly and want to check if a Class exists before querying it.
I know one way would be to store all the names of the class in a dedicated class just with the names of the created classes and then to query that. I am wondering if there is a more direct approach
I think there is not yet a method implemented to check if the class exist. What you can do, is do a query on the class name and if it returns an empty list of objects, it is fair to assume that the class does not exist.
You can make a get request on the "schema api" for the class whose existence you want to check.
If the class is not found then an error message is returned clearly stating that the class doesn't exist/ not found.
Here is the link showing how to make a fetch request on the class schema:
http://parseplatform.github.io/docs/rest/guide/#fetch-the-schema
Hope it helps!
So I am running into some issues when I am trying to load information from a file.
myMutableArray=[[NSKeyedUnarchiver unarchiveObjectWithFile:dataFile]retain];
This is the line that gives me the NSinvocation problems
* NSInvocation: warning: object 0xf9f500 of class 'myClass' does not implement methodSignatureForSelector: -- trouble ahead
* NSInvocation: warning: object 0xf9f500 of class 'myClass' does not implement doesNotRecognizeSelector: -- abort
I have looked through other questions and other sites to try and find an answer.myClass does inherit from NSObject, and my customer view controller inherits from UIViewController. My customer view controller implements the code above. The save file I am loading from does exist. Not sure what I need to do for this, any help would be appreciated thanks!
So I had an issue within myClass that I was not encoding something but I was trying to decode it after. I just had to add a line of code and delete my old save file.
Anyone know how to get the sender class/module in ruby?
caller[0] is helpful to derive the filename and linenumber sending.
But knowing the class would be helpful. Can't find it any searches?
This would be impossible. You shouldn't be specialising your behaviour in a method based on the calling class anyway.
Think about it this way - the caller could be an anonymous function (proc) created in one class, then given to another one and invoked from a third place. You wouldn't get anything useful.
Instead, I'd look at what you're trying to achieve here, and think of another way to get there! :)
Check out this gem: https://github.com/asher-/sender
I'm trying to call a function, and VS gives me an error (red underline), and i have the option to "generate method stub". What is this?
The generate method stub will generate you a method which looks exactly like you've written it, with the same parameters. Probably are getting this error because you've misspelled the method or because it is in a different namespace.
It means that you're trying to call the function incorrectly; check to make sure you've spelled the method name correctly, and that you're passing it the proper number and types of arguments.
It means you typed a wrong signature, so VS assumes this method doesn't exist. By using the shortcut VS can help you create the method as a stub (i.e. the signature, then you have to fill out the implementation).
ahh I had
method(button.Tag);
and a declaration of
void method(int tag)
so i fixed it with
method(int.Parse(button.Tag.toString()));
i tried that before, but I forgot to put "toString", since I thought it was already an int... stupid little mistake. thx guys
How to extract a name of the class from its object?
For example I have a #list object which I know is surely an instance of List class. But how do I extract that directly in code?
This kind of information is rather basic Ruby programming. The answer is:
object.class
Extra tip for the next time: try finding this information yourself in the core library documentation. You know you have some kind of object, just start reading the documentation and you will find some method that suites your needs. Information about the methods you can perform on an object can be found here.
If you want to test for an instance of a specific class, I'd go with something like:
#list.is_a?(List)
Like Edwin said, object.class will give you the corresponding Class object. If you just want the name of the class, use object.class.name.