lqf
lqf

Reputation: 299

Use NSString in different file

I have two files(file1.m and file2.m) and two strings(NSString *str1 = [[NSString alloc] initWithString:@"hello!"] in file1.m and NSString *str2 in file2.m).I set str2 = str1 by a method and then the str2's value is "hello!".

Then I change the str2 to "hello hello!" in file2.m,and i want the str1 in file1.m is also changed to "hello hello!".

How to do? If you konw,please tell me.

Thank you!

Upvotes: 1

Views: 122

Answers (2)

agentfll
agentfll

Reputation: 858

properties. when one changes, change the other.

Upvotes: 0

wadesworld
wadesworld

Reputation: 13743

How would you do the same thing in C, or Java, or most any other language? While the syntax differs, the general concepts of using a global variable, a function, or class methods does not.

In short, it appears you need some more study and just providing some code wouldn't do much to help.

Upvotes: 3

Related Questions