【发布时间】:2017-10-17 12:10:48
【问题描述】:
- (void) tapGesture: (id)sender
{
UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
NSInteger userID = gesture.view.tag;
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
OthersProfile *vc = (OthersProfile*)[storyboard instantiateViewControllerWithIdentifier:@"othersprofile"];
NSString *strUserID = [NSString stringWithFormat:@"%ld", (long)userID];
vc.userID = strUserID;
[self.viewController.navigationController pushViewController:vc
animated:YES];
}
它曾经与 Xcode 8 / Swift 3 一起工作,但似乎 Xcode 9 和 Swift 4 存在问题。
我遇到属性 userID not found 错误。
在 Swift 文件中:
var userID : String = ""
override func viewDidLoad() {
print(userID) //no value here
}
有人知道吗?
【问题讨论】:
-
你确定这段代码在 XCode8 中有效吗?
-
@PuneetSharma 抱歉我更新了我的问题
-
Swift 4 不再向 Objective-C 运行时公开所有内容,因此您可能必须使用
@objc注释属性
标签: ios objective-c swift xcode swift4