[Solved] How can i convert string to date with some strange format

You can use this function to get date from your string. – (NSDate *) dateFromServerAttributeDateFormat:(NSString *)dateString { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”yyyy-MM-dd’T’HH:mm:ss.SSS”]; [dateFormatter setLocale:[NSLocale currentLocale]]; if (!dateString.length){ return nil; } else return [dateFormatter dateFromString:dateString]; } in swift func dateFromServerString(dateString:String) -> NSDate { let dateFormater = NSDateFormatter() dateFormater.dateFormat = “yyyy-MM-dd’T’HH:mm:ss.SSS” dateFormater.locale = NSLocale.currentLocale() … Read more

[Solved] Why does my App lags when scrolling UICollectionView (Swift)? [closed]

For the future, it is better to post the relevant code here rather than post an image of all the code. You can start off with changing the cellForItemAtIndexPath implementation. You are downloading the image in the method (as a synchronous implementation). So unless the image is downloaded by contentsOfURL: and rendered, the cell won’t … Read more

[Solved] How do you add a textview to a image view?

Suppose you’ve already got a UIImage img, then use the following code to add texts -(void)drawText:(NSString *)text onImage:(UIImage *)img { UIFont *font = yourTextViewFont; UIGraphicsBeginImageContext(img.size); [img drawAtPoint:CGPointZero]; CGContextSetRGBFillColor(UIGraphicsGetCurrentContext(), 1.0, 1.0, 1.0, 1); [text drawAtPoint: CGPointMake(20, 20) withFont: font]; UIImage *ret = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return ret; } solved How do you add a textview to a … Read more

[Solved] How can I compare the current time with a specific time?

Don’t use a label to hold information. Save the date at the moment you set your label’s text, as a Date, into your model (or simply as a property in your view controller.) Then, when you need to tell If the “label time” is before or after 4:00PM, use the Calendar method date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:) to generate … Read more