這個錯誤很神奇,變數內容都有,但是 xcode 會報錯誤。
我的解法很簡單,因為可以透過 String(describing: your_object) 把物件變成字串,所以直接判斷 String 的內容即可。source code:
let preventCopyPaste: Bool? = restrictionsPayloadString.contains("- preventCopyPaste<Bool>: true")
實際上 restrictionsPayload 物件內容:
restrictionsPayload: Class Type: RestrictionsPayload - preventCopyPaste<Bool>: true - restrictDocumentToApps<Bool>: true - allowedApplications<Array<String>>: [] - printingEnabled<Bool>: false - enableDataLossPrevention<Bool>: true - enableWatermark<Bool>: true - watermarkOverlay<Optional<String>>: Optional("中華電信 max") - preventCustomKeyboards<Bool>: false - enableMailComposing<Bool>: false - enableLocationReporting<Bool>: true - enableDataBackup<Bool>: false - enableCameraAccess<Bool>: true
試了以下的解法,完成無作用
modify schema:
In this configuration, if your project build settings does not allow testability in this release mode then setting custom breakpoints or app crashes do not let you debug properly and you are served the fatal error: call of deleted method
Check the project build settings for “testability“.
Ensure it is “Yes” for the build configuration you are testing under.
In my case, I temporarily enabled testability for Release by making it Yes.
附上可能有問題的 Object
@objc(AWProfile) public class Profile : NSObject { /** @name Generic Profile Information */ public private(set) var displayName: String? public private(set) var comments: String? public private(set) var identifier: String? public private(set) var organization: String? public private(set) var uuid: String? public private(set) var version: Int? public internal(set) var profileType: AWSDK.AWSDK.ConfigurationProfileType public private(set) var isSDKProfile: Bool public private(set) var timeStamp: TimeInterval? public private(set) var dictionaryToStore: [String : Any] /** @name SDK Profile Payloads */ public private(set) var geofencePayload: AWSDK.GeofencePayload? public private(set) var analyticsPayload: AWSDK.AnalyticsPayload? public private(set) var restrictionsPayload: AWSDK.RestrictionsPayload? public private(set) var compliancePayload: AWSDK.CompliancePayload? public private(set) var authenticationPayload: AWSDK.AuthenticationPayload? public private(set) var brandingPayload: AWSDK.BrandingPayload? public private(set) var breezyPayload: AWSDK.BreezyPayload? public private(set) var customPayload: AWSDK.CustomPayload? public private(set) var offlineAccessPayload: AWSDK.OfflineAccessPayload? public private(set) var networkAccessPayload: AWSDK.NetworkAccessPayload? public private(set) var contentFilteringPayload: AWSDK.ContentFilteringPayload? public private(set) var websiteFilteringPayload: AWSDK.WebsiteFilteringPayload? @objc(initWithInfo:) public init(info: [String : Any]) } extension Profile { @objc public func toDictionary() -> [String : Any] } extension Profile { @objc override public func isEqual(_ object: Any?) -> Bool } extension Profile { @objc override public var description: String { get } } extension Profile { public class func fromData(_ data: Data) -> AWSDK.Profile? public func toData() -> Data? }
@objc(AWRestrictionsPayload) public class RestrictionsPayload : AWSDK.ProfilePayload { /** A boolean indicating if Copy and Cut actions are allowed. */ public fileprivate(set) var preventCopyPaste: Bool /** A boolean indicating if Copy and Cut actions are allowed. */ @available(swift, deprecated: 6.0, message: "preventCopyAndCut is deprecated, use preventCopyPaste instead") public fileprivate(set) var preventCopyAndCut: Bool /** A boolean indicating whether to only allow open document in allowed list of app */ public fileprivate(set) var restrictDocumentToApps: Bool /** A list of Apps that're allowed to open documents */ public fileprivate(set) var allowedApplications: [String] /** A boolean indicating if printing is allowed. */ public fileprivate(set) var printingEnabled: Bool /** A boolean indicating if data loss prevention is enabled. */ public fileprivate(set) var enableDataLossPrevention: Bool /** A boolean indicating if watermark should be displayed on content that has watermark. */ public fileprivate(set) var enableWatermark: Bool /** The string that indicate the watermark overlay on the content. */ public fileprivate(set) var watermarkOverlay: String? public fileprivate(set) var enableMailComposing: Bool public fileprivate(set) var enableLocationReporting: Bool public fileprivate(set) var enableDataBackup: Bool public fileprivate(set) var enableCameraAccess: Bool override public class func payloadType() -> String }