开发者

Use NSString in different file

开发者 https://www.devze.com 2023-01-11 01:34 出处:网络
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 m

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!


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.


properties. when one changes, change the other.

0

精彩评论

暂无评论...
验证码 换一张
取 消