Monday, April 29, 2013

NSBundle allBundles example ios


allBundles

Returns an array of all the application’s non-framework bundles.
+ (NSArray *)allBundles
Return Value
An array of all the application’s non-framework bundles.
Discussion of [NSBundle allBundles]
The returned array includes the main bundle and all bundles that have been dynamically created but doesn’t contain any bundles that represent frameworks.
Example of [NSBundle allBundles]
- (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;
}