Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xcode 10 compile issue with property text #786

Open
promlife opened this issue Jun 12, 2018 · 4 comments
Open

xcode 10 compile issue with property text #786

promlife opened this issue Jun 12, 2018 · 4 comments

Comments

@promlife
Copy link

when i compile with xcode 10 beta , lable's attribute text has error report (Value of type 'Any' has no member 'range') ,it's ok when compile with xcode 9.3

guard let range = self.infoLabel.text?.range(of: freeText) else { return }

@alejandrodau
Copy link

alejandrodau commented Aug 7, 2018

same issue when comparing the text attribute to another string (Binary operator '!=' cannot be applied to operands of type 'Any?' and 'String'). Is it ok to cast it?

@promlife
Copy link
Author

promlife commented Aug 8, 2018

@alejandrodau I solve the issue by case text as string
(contentLabel.text as? String)?.range(of: attText)

@rollr76518
Copy link

same problem, solve with below code.

func URLLabelText() -> String? { return URLLabel.text as! String? }

@stevenelson94708
Copy link

I encountered the same problem with Xcode 10.1 (works fine with Xcode 9.4.1) where the text property appears to be compiled as Any instead of as String, giving the error "Value of type 'Any' has no member 'nsRangeFromRange'" .

So a workaround for the time being is to cast text as String:

let range : NSRange = (label.text! as! String).nsRangeFromRange(range: (label.text! as! String).range(of: attribText)!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants