From d64ea284fb05fd50ad3264e9ef161dd9cfb0d18d Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Sat, 6 Apr 2013 16:20:21 -0400 Subject: [PATCH] Fixed: CPBundle -bundleWithIdentifier did not create CPBundle when necessary. Previously, if a CFBundle with the given identifier had been loaded, but no CPBundle had yet been created with the given identifier, -bundleWithIdentifier would return nil instead of a newly constructed CPBundle with the CFBundle's URL. This commit correctly returns a newly constructed CPBundle when a CFBundle is found. --- Foundation/CPBundle.j | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index 9544ec98c..817ba6717 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -56,9 +56,17 @@ var CPBundlesForURLStrings = { }; var bundle = CFBundle.bundleWithIdentifier(anIdentifier); if (bundle) - bundle = CPBundlesForURLStrings[bundle.bundleURL().absoluteString()] || nil; + { + var url = bundle.bundleURL(), + cpBundle = CPBundlesForURLStrings[url.absoluteString()]; - return bundle; + if (!cpBundle) + cpBundle = [self bundleWithURL:url]; + + return cpBundle; + } + + return nil; } + (CPBundle)bundleForClass:(Class)aClass