I am getting the values from UITextfield into NSString , need to convert the values of NSString into CGPoint, Suppose if i enter 6,5 into textfield it should covert it into CGPoint.
A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.
(NSString *) is simply the type of the argument - a string object, which is the NSString class in Cocoa. In Objective-C you're always dealing with object references (pointers), so the "*" indicates that the argument is a reference to an NSString object.
See CGPointFromString (documentation in link). The string has to be in the format {x,y}
so you would need to add those to the user input yourself:
CGPoint myPoint = CGPointFromString([NSString stringWithFormat:@"{%@}",textField.text]);
Will return CGPointZero if the string is invalid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With