Skip to content

Instantly share code, notes, and snippets.

@kejinlu
Created March 27, 2012 05:17
Show Gist options
  • Save kejinlu/2212718 to your computer and use it in GitHub Desktop.
Save kejinlu/2212718 to your computer and use it in GitHub Desktop.
dumpInfo For Objc Class
//你得 #import <objc/runtime.h>
-(void)dumpInfoForClass:(Class)clazz
{
u_int count;
Ivar* ivars = class_copyIvarList(clazz, &count);
NSMutableArray* ivarArray = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i < count ; i++)
{
const char* ivarName = ivar_getName(ivars[i]);
[ivarArray addObject:[NSString stringWithCString:ivarName encoding:NSUTF8StringEncoding]];
}
free(ivars);
objc_property_t* properties = class_copyPropertyList(clazz, &count);
NSMutableArray* propertyArray = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i < count ; i++)
{
const char* propertyName = property_getName(properties[i]);
[propertyArray addObject:[NSString stringWithCString:propertyName encoding:NSUTF8StringEncoding]];
}
free(properties);
Method* methods = class_copyMethodList(clazz, &count);
NSMutableArray* methodArray = [NSMutableArray arrayWithCapacity:count];
for (int i = 0; i < count ; i++)
{
SEL selector = method_getName(methods[i]);
const char* methodName = sel_getName(selector);
[methodArray addObject:[NSString stringWithCString:methodName encoding:NSUTF8StringEncoding]];
}
free(methods);
NSDictionary* classDump = [NSDictionary dictionaryWithObjectsAndKeys:
ivarArray, @"ivars",
propertyArray, @"properties",
methodArray, @"methods",
nil];
NSLog(@"%@", classDump);
}
@kejinlu
Copy link
Author

kejinlu commented Mar 27, 2012

UINavigationController

{
    ivars =     (
        "_containerView",
        "_navigationBar",
        "_navigationBarClass",
        "_toolbar",
        "_navigationTransitionView",
        "_currentScrollContentInsetDelta",
        "_previousScrollContentInsetDelta",
        "_previousScrollContentOffsetDelta",
        "_bottomInsetDelta",
        "_disappearingViewController",
        "_delegate",
        "_savedNavBarStyleBeforeSheet",
        "_savedToolBarStyleBeforeSheet",
        "_navigationControllerFlags",
        "_toolbarClass"
    );
    methods =     (
        "setDetailViewController:",
        detailViewController,
        isExpanded,
        "setIsExpanded:",
        defaultFirstResponder,
        "viewDidMoveToWindow:shouldAppearOrDisappear:",
        navigationBar,
        "setNavigationBar:",
        "navigationBarDidChangeOpacity:",
        "navigationBar:shouldPopItem:",
        "navigationBarDidResizeForPrompt:",
        "navigationBar:buttonClicked:",
        editing,
        "setEditing:animated:",
        "shouldAutorotateToInterfaceOrientation:",
        contentSizeForViewInPopover,
        isModalInPopover,
        "_isPresentationContextByDefault",
        "initWithNibName:bundle:",
        "_shouldPersistViewWhenCoding",
        loadView,
        "setSearchBarHidNavBar:",
        viewDidUnload,
        "_updateLayoutForStatusBarAndInterfaceOrientation",
        "updateTitleForViewController:",
        "viewWillAppear:",
        "viewDidAppear:",
        "viewWillDisappear:",
        "viewDidDisappear:",
        "purgeMemoryForReason:",
        "_shouldChildViewControllerUseFullScreenLayout:",
        "_reallyWantsFullScreenLayout",
        "_frameForContainerViewInSheetForBounds:displayingTopView:andBottomView:",
        "_isSupportedInterfaceOrientation:",
        modalTransitionStyle,
        "_allowsAutorotation",
        rotatingHeaderView,
        rotatingFooterView,
        "willRotateToInterfaceOrientation:duration:",
        "_shouldUseOnePartRotation",
        "willAnimateRotationToInterfaceOrientation:duration:",
        "willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:",
        "willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:",
        "_getRotationContentSettings:",
        "didAnimateFirstHalfOfRotationToInterfaceOrientation:",
        "didRotateFromInterfaceOrientation:",
        searchBarHidNavBar,
        "setContentSizeForViewInPopover:",
        "_viewForContentInPopover",
        "_willBecomeContentViewControllerOfPopover:",
        "_didBecomeContentViewControllerOfPopover:",
        "_didResignContentViewControllerOfPopover:",
        "_prepareForPresentationInPopover:",
        "_prepareForDismissalInPopover:",
        defaultPNGName,
        "updateTabBarItemForViewController:",
        tabBarItem,
        "_moreListTitle",
        moreListImage,
        moreListSelectedImage,
        moreListTableCell,
        "_updateToolbarItemsFromViewController:animated:",
        disappearingViewController,
        "setDisappearingViewController:",
        "pushViewController:animated:",
        "setNavigationBarClass:",
        "_setToolbarClass:",
        "_releaseContainerViews",
        topViewController,
        visibleViewController,
        "setViewControllers:animated:",
        "_transitionForOldViewControllers:newViewControllers:",
        "_setViewControllers:transition:",
        needsDeferredTransition,
        isNavigationBarHidden,
        "_navigationItems",
        setNeedsDeferredTransition,
        "_hideOrShowBottomBarIfNeededWithTransition:",
        "_startDeferredTransitionIfNeeded",
        "_positionNavigationBarHidden:",
        "setNavigationBarHidden:animated:",
        "_setNavigationBarHidden:edgeIfNotNavigating:duration:",
        "_setNavigationBarHidden:edge:duration:",
        wasLastOperationAnimated,
        lastOperation,
        "_animationParametersForHidingNavigationBar:lastOperation:edge:duration:",
        "_positionNavigationBarHidden:edge:",
        "_hideShowNavigationBarDidStop:finished:context:",
        "_layoutTopViewController",
        "_layoutTopViewControllerInSheet",
        isToolbarHidden,
        "_positionToolbarHidden:",
        "_configureToolbar",
        "setToolbarHidden:animated:",
        "_setToolbarHidden:edge:duration:",
        "_positionToolbarHidden:edge:",
        "_existingToolbar",
        toolbar,
        "_hideShowToolbarDidStop:finished:context:",
        "_updateBarsForCurrentInterfaceOrientation",
        navigationTransitionView,
        "_restoreOriginalInsetAndOffsetToScrollView:",
        "_clearLastOperation",
        "didShowViewController:animated:",
        "setNeedsDeferredTransition:",
        "_applyScrollContentInsetDelta:toScrollView:",
        "_applyScrollContentOffsetDelta:toScrollView:",
        "_isNavigationBarVisible",
        "_hasTranslucentNavigationBarIncludingViewController:",
        "_shouldNavigationBarInsetViewController:",
        "_layoutViewController:",
        "_scrollViewBottomContentInset",
        "_computeAndApplyScrollContentInsetDeltaForViewController:",
        "_frameForViewController:",
        "willShowViewController:animated:",
        "_navigationTransitionForUITransition:",
        "navigationTransitionView:didEndTransition:fromView:toView:",
        "_startTransition:fromViewController:toViewController:",
        "pushViewController:transition:forceImmediate:",
        "_popViewControllerWithTransition:allowPoppingLast:",
        "_shouldBottomBarBeHidden",
        previousViewController,
        "_snapshotView",
        "_shouldPopFromLandscapeToPortraitOrientation",
        "_popViewControllerAndUpdateInterfaceOrientationAnimated:",
        "popViewControllerAnimated:",
        "popToRootViewControllerWithTransition:",
        "popToViewController:transition:",
        "popViewControllerWithTransition:",
        "popToViewController:animated:",
        makeModalViewControllerTopViewController,
        "_doesTopViewControllerSupportInterfaceOrientation:",
        bottomViewController,
        "_layoutTopViewControllerInSheetWithPopoverView:",
        pretendNavBarHidden,
        "_adjustedContentSizeForPopover:",
        "_layoutTopViewControllerOutOfSheet",
        "initWithRootViewController:",
        "initWithNavigationBarClass:toolbarClass:",
        viewControllers,
        "setViewControllers:",
        navigationBarClass,
        "setNavigationBarHidden:",
        "setPretendNavBarHidden:",
        avoidMovingNavBarOffscreenBeforeUnhiding,
        "setAvoidMovingNavBarOffscreenBeforeUnhiding:",
        "_sendNavigationBarToBack",
        "setToolbar:",
        "setToolbarHidden:",
        isShown,
        "_isTransitioning",
        "navigationTransitionView:didStartTransition:",
        "navigationTransitionView:durationForTransition:",
        "_deferredTransition",
        "__viewWillLayoutSubviews",
        "pushViewController:transition:",
        "_resetBottomBarHiddenState",
        "_updateBottomBarHiddenState",
        "_tabBarControllerDidFinishShowingTabBar:",
        "popViewControllerWithAnimationTransition:duration:curve:",
        "popToRootViewControllerAnimated:",
        "popToViewControllerWithSnapbackIdentifier:animated:",
        "_toolbarClass",
        dealloc,
        "initWithCoder:",
        "encodeWithCoder:",
        "setDelegate:",
        delegate
    );
    properties =     (
        detailViewController,
        isExpanded,
        topViewController,
        visibleViewController,
        viewControllers,
        navigationBarHidden,
        navigationBar,
        toolbarHidden,
        toolbar,
        delegate,
        needsDeferredTransition,
        navigationTransitionView,
        pretendNavBarHidden,
        avoidMovingNavBarOffscreenBeforeUnhiding,
        disappearingViewController,
        previousViewController,
        bottomViewController,
        "_toolbarClass"
    );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment