2023-06-27_20-46-21.2650_+0800-2c9fc131155823f7a89d2dcb384c8538fe2ec1b2.crash
Post
Replies
Boosts
Views
Activity
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
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)
}
+ (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);
}
}
}