-
-
Save mimay/6266502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSObject+JTNibLoader.h | |
| // | |
| // Created by james on 8/22/11. | |
| // | |
| #import <Foundation/Foundation.h> | |
| @interface NSObject (JTNibLoader) | |
| + (id)objectWithNibNamed:(NSString *)nibName; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NSObject+JTNibLoader.m | |
| // | |
| // Created by james on 8/22/11. | |
| // | |
| #import "NSObject+JTNibLoader.h" | |
| @implementation NSObject (JTNibLoader) | |
| + (id)objectWithNibNamed:(NSString *)nibName { | |
| NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:nil options:nil]; | |
| for(id currentObject in topLevelObjects) | |
| { | |
| if([currentObject isKindOfClass:[self class]]) | |
| { | |
| return currentObject; | |
| break; | |
| } | |
| } | |
| return nil; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment