I want to check the conditon in my first class on the base of second class string.i mean i have a string mystr开发者_如何学编程 in second class which contain the value like "sarab".Now i want to use condition in first class that if mystr="anything..".But i am not able to check the condtion.I dont know how to use second class string.Actually i have made one method in second class where i store the string value.Please tell me how i check the value of the string.My second class code is like that:
second.m
(void)mystrmethod
{
mystr=[[NSMutableString alloc]init];
mystr=@"sarab";
NSLog(@" %@ ",mystr);
}
Now i want to check this str in my first class. Thank you
make this string variable global. then u can use this.
In your firstclass you need to import the second class like
#import "second.h"
and then you need to make an object of it like
Second *obj=[[Second alloc]init];
and then you can check the string value using
if{ [obj.mystr isEqualToString @"sarab"]}{
//then do something here
}
but all this work only if you define the string first and then compare it ..
hope this helps...
Declare your string in the appdelegate file and access it where ever you want using :
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if([appDelegate.<yourString> isEqualToString:@"<compareString>"]){
NSLog(@"appDelegate.<yourString> = %@",appDelegate.<yourString>);
}
精彩评论