• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Determining which bundle an EOModel comes from
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining which bundle an EOModel comes from


  • Subject: Re: Determining which bundle an EOModel comes from
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 13 Jan 2009 18:39:09 -0800

How about checking if model.pathURL().startsWith(aBundle.bundlePathURL()). With aBundle being one of NSBundle.allBundles()?


Chuck



On Jan 2, 2009, at 4:50 AM, Hugi Thordarson wrote:

Hi all, happy new year!

Does anyone here have a reliable way to find what bundle a loaded EOModel is in? I'm currently using the little bugger below, but obviously it will fail if the model does not contain any entites or if the entities are using EOGenericRecord as the class (rare, but happens).

--------
	/**
	 * Attempts to resolve which framework/bundle an EOModel belongs to.
	 */
	public static String bundleNameForEOModel( EOModel model ) {
		NSArray<EOEntity> entities = model.entities();

		if( entities == null || entities.count() == 0 )
			return null;

		EOEntity entity = entities.lastObject();
		String className = entity.className();

		try {
			Class<?> clazz = Class.forName( className );
			return NSBundle.bundleForClass( clazz ).name();
		}
		catch( ClassNotFoundException e ) {
			logger.error( "No bundle found for class: " + className, e );
			return null;
		}
	}
--------

Cheers,
- Hugi

// Hugi Thordarson
// http://hugi.karlmenn.is/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

-- Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Determining which bundle an EOModel comes from (From: Hugi Thordarson <email@hidden>)

  • Prev by Date: Re: Problem File Upload WO 5.4 WONDER 5.0.0.8764
  • Next by Date: Re: EO Not deleting
  • Previous by thread: Determining which bundle an EOModel comes from
  • Next by thread: Updating SiteConfig.xml manually
  • Index(es):
    • Date
    • Thread