Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIView之间的NSString转换_Objective C_Xcode_Nsstring - Fatal编程技术网

Objective c UIView之间的NSString转换

Objective c UIView之间的NSString转换,objective-c,xcode,nsstring,Objective C,Xcode,Nsstring,我想从一个UIView在另一个UIView中使用NSString NSString *firstNameTemp = [[[[html componentsSeparatedByString:@"<first_name>"] objectAtIndex:1] componentsSeparatedByString:@"</first_name>"] objectAtIndex:0]; NSString *lastNameTemp = @"Михаил"; 在第一个u

我想从一个
UIView
在另一个
UIView
中使用
NSString

NSString *firstNameTemp =  [[[[html componentsSeparatedByString:@"<first_name>"] objectAtIndex:1] componentsSeparatedByString:@"</first_name>"] objectAtIndex:0];
NSString *lastNameTemp =  @"Михаил";
在第一个
ui视图中创建
NSString
有两种方法

NSString *firstNameTemp =  [[[[html componentsSeparatedByString:@"<first_name>"] objectAtIndex:1] componentsSeparatedByString:@"</first_name>"] objectAtIndex:0];
NSString *lastNameTemp =  @"Михаил";
编码有问题,但如果我用
NSString
创建
UILabel
,它会显示正确的字符串(Мааа)

在第二个
ui视图中
如果使用方法

- (void) initPhotoViewWithFrame:(CGRect)frame Image:(UIImage *)image Name:(NSString *)name;
当我尝试使用firstNameTemp时,我得到一个错误

但是如果我使用lastnamtemp,则不会出现错误


问题是:如何成功地传递第一个
NSString
firstNameTemp)?

这是一个内存管理错误。您必须保留
firstNameTemp
(稍后再发布)。严格来说,
lastNameTemp
也是如此,但是这个错误并没有出现,因为字符串文本(
@“…”
)是由编译器创建的,并且在进程的生命周期内一直存在。

当它在标签中显示正确的字符串时,然后将yourlable.text(它也是字符串)传递给另一个视图。这是最不可取的方式。因为在第一个UIView中,我只有UIWebView>>存在编码问题,但如果我使用NSString创建UILabel,它会显示正确的字符串(Мааа)看看我的问题——希望它能帮上忙!它起作用了!还有一个问题:我应该在initPhotoViewWithFrame方法中还是在first-UIView dealloc中释放它?