Monday, April 29, 2013

NSBundle allFrameworks example ios


allFrameworks

Returns an array of all of the application’s bundles that represent frameworks.
+ (NSArray *)allFrameworks
Return Value of [NSBundle allFrameworks]
An array of all of the application’s bundles that represent frameworks. Only frameworks with one or more Objective-C classes in them are included.
Discussion of [NSBundle allFrameworks]
The returned array includes frameworks that are linked into an application when the application is built and bundles for frameworks that have been dynamically created.
Example of [NSBundle allFrameworks]
- (NSManagedObjectModel *) mergedManagedObjectModel 
{   
    if (!mergedManagedObjectModel) 
    {
     NSMutableSet *allBundles = [[[NSMutableSet alloc] init] autorelease];
     [allBundles addObjectsFromArray: [NSBundle allBundles]];
     [allBundles addObjectsFromArray: [NSBundle allFrameworks]];

     mergedManagedObjectModel = [[NSManagedObjectModel mergedModelFromBundles: [allBundles allObjects]] retain];
    }

    return mergedManagedObjectModel;
}