Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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
Ios 为什么我不能在xcode中设置属性的值?_Ios_Objective C - Fatal编程技术网

Ios 为什么我不能在xcode中设置属性的值?

Ios 为什么我不能在xcode中设置属性的值?,ios,objective-c,Ios,Objective C,仅>>>>NSLog@%@,_currentPost[@postString];打印出正确的字符串 NSLog@%@,postTextView.text;打印空为什么 如何将值传递给textView.text 为什么我不能将字符串传递给textView,也不能传递给标签 #import <UIKit/UIKit.h> #import <Parse/Parse.h> @interface JCPostTableViewCell : UITableViewCell @pr

仅>>>>NSLog@%@,_currentPost[@postString];打印出正确的字符串

NSLog@%@,postTextView.text;打印空为什么

如何将值传递给textView.text

为什么我不能将字符串传递给textView,也不能传递给标签

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface JCPostTableViewCell : UITableViewCell

@property (strong, nonatomic) PFObject *currentPost;

@property (strong, nonatomic) IBOutlet UITextView *postTextView;

@end

我的猜测是,IB中没有连接插座,因此您实际上是在呼叫:

NSLog(nil);
这将不会产生任何产出。您应该使用常量字符串作为NSLog的格式字符串,如果您这样做,您将至少看到空输出:

NSLog(@"%@", self.postViewText.text);
在方法开头添加以下代码,以验证插座是否已连接:

NSAssert(self.postViewText, @"postViewText outlet not connected!");

您无法连接插座连接

与相同,在该检查之后连接textview并设置委托方法

NSLog(@"%@", self.postViewText.text);

这不是您使用NSLog的方式。它将显示警告,不要忽略警告。将NSLog与格式字符串一起使用以防止内存错误。我猜是插座未连接且为零。请验证。您是对的,我如何连接IB中的插座?谢谢您的回答。NSLog只是为了测试,我的重点是如何将postString传递给textView.text?一旦连接了插座,您的代码就会这样做。插座已连接:
NSLog(@"%@", self.postViewText.text);