- (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找不到错误。
在Swift文件中:
var userID : String = ""
override func viewDidLoad() {
print(userID) //no value here
}
有任何想法吗?
尝试以下方法:
@objc var userID : String = "
在Swift 4中更改了将Swift代码暴露给Objective-C的规则。因此,您的代码在Swift 3中还可以,因此您将面临混乱;)
相应的Swift Evolution提案中对新设计进行了详细说明。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句