Latest 1.1.4
Homepage https://github.com/kobe1941/FFExtension
License MIT
Platforms ios 8.0, requires ARC
Authors

pod FFExtension weibo status

ARC iOS8.0+

中文介绍

Start

$ pod 'FFExtension'

You need import one head file just like import <FFManager.h> .

Then put the code below in your project, maybe in application:didFinishLaunchingWithOptions: method, make sure the calss will not dealloc in all app life.

__weak typeof(self) weakSelf = self;
[[FFManager sharedInstance] startWorkWithOption:FFHookOptionAll unrecogziedSelectorClassPrefixs:@[@"SSZ"] callBackBlock:^(NSDictionary *exceptionDic) {
        [weakSelf reportExecptionToBugly:exceptionDic];
}];

just like this:

#pragma mark - Report Exception To Bugly
- (void)reportExecptionToBugly:(NSDictionary *)exceptionDic
{
    if (exceptionDic) {
        NSString *name = [exceptionDic objectForKey:FF_Name];
        NSString *reason = [exceptionDic objectForKey:FF_Reason];
        NSDictionary *extraDic = [exceptionDic objectForKey:FF_ExtraDic];
        NSArray *callStack = [exceptionDic objectForKey:FF_CallStackSymbols];

        [Bugly reportExceptionWithCategory:3 name:name reason:reason callStack:callStack            extraInfo:extraDic terminateApp:NO];
    }
}

Tips: classPrefixs is your own calsses that you want to avoid unrecogzied selector sent to instance crash.

- (void)startWorkWithOption:(FFHookOption)option unrecogziedSelectorClassPrefixs:(NSArray<NSString *> *)classPrefixs callBackBlock:(FFExceptionBlock)block;

Safe method for example

NSArray

- (BOOL)writeToURL:(NSURL *)url error:(NSError * _Nullable __autoreleasing *)error;
- (id)objectAtIndexedSubscript:(NSUInteger)index;
- (id)objectAtIndexedSubscriptArrayM:(NSUInteger)index;
- (id)objectAtIndex:(NSUInteger)index;
- (instancetype)initWithObjects:(const id _Nonnull [_Nullable])objects count:(NSUInteger)cnt;
- (NSArray *)arrayByAddingObject:(id)anObject;
- (void)getObjects:(id _Nonnull __unsafe_unretained [_Nonnull])objects range:(NSRange)range;
- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range;
- (NSUInteger)indexOfObjectIdenticalTo:(id)anObject inRange:(NSRange)range;
- (NSArray *)subarrayWithRange:(NSRange)range;
- (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes;
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;
- (void)removeObjectsInRange:(NSRange)range;
- (void)removeObjectsAtIndexes:(NSIndexSet *)indexes;
- (void)removeObject:(id)anObject inRange:(NSRange)range;
- (void)removeObjectAtIndex:(NSUInteger)index;
- (void)removeObjectAtIndexArrayM:(NSUInteger)index;
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
- (void)removeObjectIdenticalTo:(id)anObject inRange:(NSRange)range;
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
- (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray;
- (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray range:(NSRange)otherRange;
- (void)insertObjects:(NSArray *)objects atIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(NSArray *)objects;

and so on …


By use method swizzle to do this , no try-catch .

Have a nice day !

Latest podspec

{
    "name": "FFExtension",
    "version": "1.1.4",
    "platforms": {
        "ios": "8.0"
    },
    "license": "MIT",
    "homepage": "https://github.com/kobe1941/FFExtension",
    "authors": {
        "hufeng": "[email protected]"
    },
    "source": {
        "git": "https://github.com/kobe1941/FFExtension.git",
        "tag": "1.1.4"
    },
    "summary": "To reduce the crash in ios app",
    "description": "if you have any problem or crash with use FFExtension, please issue me and paste detail crash logs,  Have a nice day(#^.^#).",
    "requires_arc": true,
    "subspecs": [
        {
            "name": "Core",
            "source_files": "FFExtension/Classes/Core/*.{h,m}"
        },
        {
            "name": "MRC",
            "source_files": "FFExtension/Classes/MRC/*.{h,m}",
            "requires_arc": false,
            "compiler_flags": "-ObjC",
            "dependencies": {
                "FFExtension/Core": []
            }
        },
        {
            "name": "Foundation",
            "source_files": "FFExtension/Classes/Foundation/*.{h,m}",
            "dependencies": {
                "FFExtension/MRC": [],
                "FFExtension/Core": []
            }
        }
    ]
}

Pin It on Pinterest

Share This