我是iPhone开发的新手,我想从String
中的另一个类调用一个方法在LoginSuccess.m中
- (void)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
在Register.m
中LoginSuccess *loginViewInstance = [[LoginSuccess alloc]initWithNibName:@"LoginSuccess" bundle:nil];
[loginViewInstance Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];
执行上面的,但我想在String中调用该方法,如
NSString *result = [loginViewInstance Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];
有什么想法吗?提前谢谢。
答案 0 :(得分:7)
替换
- (void)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
与
- (NSString *)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
{
NSString *str;
str = someValue;
return str;
}
答案 1 :(得分:0)
您的返回类型数据是(void)。请先用NSString替换它,如:
(NSString *)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
{
//do something
}
然后从另一个类调用一个方法就可以了 比如先在Register.m中添加这段代码。
#import "LoginSuccess.h"
然后将其称为:
LoginSuccess *Call_String = (LoginSuccess *)[LoginSuccess sharedApplication];
NSString *result = [Call_String Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];
希望你的问题能够得到解决