Post

Replies

Boosts

Views

Activity

Reply to UITextView Crashes on iOS 17 [NSInternalInconsistencyException attempt to create NSTextRange from nil location
func validVS16String() -> (Bool, String) { guard #available(iOS 17.0, *) else { return (true, self) } guard unicodeScalars.contains(where: { $0.properties.isVariationSelector }) else { return (true, self) } var valid = true var validScalars: [Unicode.Scalar] = [] var preScalar: Unicode.Scalar? for v in unicodeScalars { if v.properties.isVariationSelector, preScalar?.properties.isEmoji == false { valid = false } else { validScalars.append(v) } preScalar = v } if valid { return (true, self) } let validString = String(String.UnicodeScalarView(validScalars)) return (false, validString) } try this
Jan ’24
Reply to UITextView Crashes on iOS 17 [NSInternalInconsistencyException attempt to create NSTextRange from nil location
try this func validVS16String() -> (Bool, String) { guard #available(iOS 17.0, *) else { return (true, self) } guard unicodeScalars.contains(where: { $0.properties.isVariationSelector }) else { return (true, self) } var valid = true var validScalars: [Unicode.Scalar] = [] var preScalar: Unicode.Scalar? for v in unicodeScalars { if v.properties.isVariationSelector, preScalar?.properties.isEmoji == false { valid = false } else { validScalars.append(v) } preScalar = v } if valid { return (true, self) } let validString = String(String.UnicodeScalarView(validScalars)) return (false, validString) }
Jan ’24
Reply to CoreImage createCGImage Crash
+ (void)loadBrushImage:(UIImage *)image canvasSize:(CGSize)canvasSize useCache:(BOOL)useCache complete:(void (^ _Nullable )(BOOL success))complete { if (!useCache) { [[LFBrushCache share] removeObjectForKey:LFSmearBrushImage]; } UIImage *cacheImage = [[LFBrushCache share] objectForKey:LFSmearBrushImage]; if (cacheImage) { if (complete) { complete(YES); } return; } if (image) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ UIImage *patternImage = [image LFBB_patternGaussianImageWithSize:canvasSize filterHandler:nil]; dispatch_async(dispatch_get_main_queue(), ^{ if (patternImage) { [[LFBrushCache share] setForceObject:patternImage forKey:LFSmearBrushImage]; } if (complete) { complete((BOOL)patternImage); } }); }); } else { if (complete) { complete(NO); } } }
Jan ’24