0

I'm new to iPhone development,I want to call a method from another class in String

In LoginSuccess.m

- (void)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType

In Register.m

LoginSuccess *loginViewInstance =  [[LoginSuccess alloc]initWithNibName:@"LoginSuccess" bundle:nil];
[loginViewInstance Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];

above one is executed,but I want to call that method in String like

NSString *result = [loginViewInstance Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];

Any ideas? Thanks in advance.

2 Answers 2

6

replace

- (void)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType

with

- (NSString *)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
{
    NSString *str;
    str = someValue;
    return str;
}
Sign up to request clarification or add additional context in comments.

1 Comment

On a side note @user2439531, remane your method - (void)post:(NSString *)url andSecondStr:(NSString *)postData andThirdStr:(NSString *)contentType. Using a CAPITAL LETTER on first the first letter in a variable is customary used for a class name. The Method Name Above Hurts My Eyes!
0

your return type data is (void). please first replace it with NSString like:

(NSString *)Post:(NSString *)url AndSecondStr:(NSString *)postData AndThirdStr:(NSString *)contentType
{
//do something
}

then to call a method from another class you can do it like first add this code in Register.m.

#import "LoginSuccess.h"

and then call it like:

 LoginSuccess *Call_String = (LoginSuccess *)[LoginSuccess sharedApplication];

 NSString *result = [Call_String Post:TxtEmailId AndSecondStr:TxtUserName AndThirdStr:serializeObject];   

hope your problem will be solved

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.