I am trying to find the position of a letter in a labelText . The code in Objective C is
NSRange range = [@"Good,Morning" rangeOfString:@","];
NSString *prefix = [@"Good,Morning" substringToIndex:range.location];
CGSize size = [prefix sizeWithFont:[UIFont systemFontOfSize:18]];
CGPoint p = CGPointMake(size.width, 0);
NSLog(@"p.x: %f",p.x);
NSLog(@"p.y: %f",p.y);
Please someone tell me how we write the above code in swift ? I am finding it bit difficult to calculate range of a string .