how to call class from pone class to another class - iphone

hi i am new to iphone. what i am doing is creating two classes named as classone,classtwo. now what i need is i have to call calsstwo from classone. I already import classtwo in classone. pls post some code thank u.

Init an object of type Classtwo in Classone and send it messages from there. You should probably head for some basic Objective-C stuff first: http://www.otierney.net/objective-c.html

Related

why the scala programe created by singleton object doesnt require a static main method?

I am new to scala ,and worked with java previosly.On studying i found that we can create a singleton object like given below
object Hello{
def main(a:Array[String]){
println("hello user")
}
}
If Scala uses JVM then why the scala programe created by singleton object doesnt require a static main method?
I know its a very basic question but i am a beginner.
and also if anybody can suggest me some docs online to study scala.
Thanks in advance.
Methods of singleton objects get translated into static methods (among other stuff)strong text. So you actually do have the equivalent of a static main method.
Have a look at the generated class files and you will see.

Swift : Why is the class method struck out

As long as a Swift class extends from NSObject we can pass it to the Objective-C runtime and ask it to introspect it for us.
We have three options:
class
classForCoder
classForKeyedArchiver
. . however class is struck out. (See image). Why is this?
That's because class is a keyword in Swift, therefore any valid method cannot be named class. In the same way you cannot create a method named for, while or other keyword.
I wasn't able to reproduce the strike-out with my methods, however, naming a method var (or other keyword) in obj-c makes it impossible to be called from Swift.
Edit
I was wrong. It's still possible to call class from Swift using
var clazz: AnyClass? = self.`class`()
However, then the compiler says:
'Class' is unavailable: use 'dynamicType' instead
So the answer by Edwin Vermeers is the correct one.
As you can see in the documentation, it's only available in Objective C and not in swift.
See: https://developer.apple.com/documentation/objectivec/nsobject/1571950-class
I think this is because the AnyObject gives you enough information (More than the NSObject)
for instance you can do NSStringFromClass(BaseObject) in swift instead of the NSStringFromClass([BaseObject class]) that you do in Objective C

Importing Object from other class

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).

how can i call method from another class in iPhone Xcode

i have trouble with calling method from another class this is my code
this is my method name
-(void)newDetails:(NSString *)name:(NSString *)gender:(NSString *)year:(double) in:(double)out:(NSString *)uid:(NSString *)pass:(NSString *)dob:(double) table:(double)table1{
i import my class and create object like this
#import "Personal.h"
#class Personal;
Personal *personDetails;
calling that mathod like this
[personDetails newDetails:username:categoryMale:financeYear:0:0:userID:password:dob:0:0];
calling that mathod like this
but its not working .
guide me how can call this method
Suppose you have a class A that calls function in class Personal.
In Class A.m do #import "Personal.h"
Make sure that the function is defined in the Personal.h file otherwise it will give warning.
Now In class A when you want to call that function.
you can do.
Personal *per=[Personal alloc]init];
[per newDetails:username:categoryMale:financeYear:0:0:userID:password:dob:0:0];.
Note: If you are coming from Class Personal to Class A and then you want to call a function in Class Personal then no need to create any objects you can simply use delegates.
Initialize the object
personDetails=[[Personal alloc] init] ;
Or if you have any Custom Initializer you can use that.

Class Method Example in objective -c

can anyone tell me how to create a class method and using that how can we share an object DATA in all classes......?
A class method has no state therefore can't do what you're asking for. You want to create a singleton object and pass that around. Check out Singletons, AppDelegates and top-level data for a discussion of singletons and a handy macro for automatically creating them.
-(returnType)methodName; --> this is your normal object method
+(returnType)methodName; --> this will be your class method
[Classname methodName] --> This is how you will call the class method