【发布时间】:2020-03-14 00:17:30
【问题描述】:
在 Swift 项目中包含,
CartViewModel.swift
@objc public class CartViewModel: NSObject {
let apiService: APIService
var alertMessage: String? {
didSet {
self.showAlertClosure?()
}
}
var isShow: Bool = false {
didSet {
self.updateStatus?()
}
}
@objc public var dataCount: Int {
return models.count
}
}
ListViewController.h
NS_ASSUME_NONNULL_BEGIN
@class CartViewModel;
@interface ListViewController : UIViewController
@property (nonatomic, strong) CartViewModel *viewModel;
@end
NS_ASSUME_NONNULL_END
ListViewController.m
NSLog(@"%@", self.viewModel.dataCount);
// 访问任何属性都会出现此错误
在前向类对象“CartViewModel”中找不到属性“dataCount”
【问题讨论】:
标签: ios objective-c swift mvvm viewmodel