PHCollection localizedTitle crash in iOS 14.2.1

Code Block language
PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
  for (NSInteger i = 0; i < topLevelUserCollections.count; i++) {
    PHCollection *collection = topLevelUserCollections[i];
    id value = collection.localizedTitle;
    NSLog(@"%@", value);
  }


this value is bad address

this (NSString *) value = 0xa08fc90a9a686dc6 , not a string
I found reason, my category NSString+Ext, swizzle rangeOfString:, but my method is
Code Block
+ (void)initialize
, I replace it with
Code Block
+ (void)load
, it word.
  1. Use dsc_extractor to extract the Foundation.framework out from the dyld_shared_cache_arm64, that pull down from iOS 15.6 (on $HOME/Library/Developer/Xcode/iOS\ DeviceSupport/15.6/Symbols/System/Library/Caches/com.apple.dyld/dyld_shared_cache_arm64e).
  2. Drag it to Foundation.framework/Foundation to IDA64.

So, the reason is obvious, the +[NSString initialize] will enable/disable the NSTaggedPointerString feature. If u implement one in category, your app will not recognize a Tagged Pointer String.

PHCollection localizedTitle crash in iOS 14.2.1
 
 
Q