• 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: Storing bundle loaded main class instances in NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Storing bundle loaded main class instances in NSArray


  • Subject: Re: Storing bundle loaded main class instances in NSArray
  • From: Daniel Luis dos Santos <email@hidden>
  • Date: Wed, 8 Apr 2009 13:02:18 +0100

Ok, here goes,

This is were I load the bundle :

NSString *bundlePath = (NSString*)[_configuration objectForKey: DRIVERBUNDLE_PATH];
NSBundle *bundle = [NSBundle bundleWithPath: bundlePath];


if (nil == bundle) {
[errorLog addObject: [NSNumber numberWithInt: DRIVER_ERRORCODE_BUNDLEMISSINGATPATH]];
*logList = [NSArray arrayWithArray: errorLog];
return nil;
}


Class driverClass = [bundle principalClass];
if ((nil == driverClass) || 
![driverClass conformsToProtocol: @protocol(StorageDriverInterface)]) {
[errorLog addObject: [NSNumber numberWithInt: DRIVER_ERRORCODE_BUNDLEMAINCLASSNOTCOMPLIANT]];
*logList = [NSArray arrayWithArray: errorLog];
return nil;
}
_bundle = bundle;

fine until there, then later in the same method inside a loop where I initialize several instances of the principal class:

id <StorageDriverInterface> aDriverInstance = [[driverClass alloc] init: driverConfig callingbackto: callback logTo: &interfaceInitLogList];

That instantiates the object whose class was loaded.  Then in the same loop afterwards I want to add the previous id to an NSArray

id saID = [_parametersOfLatestInitializedSA objectForKey: CONFIG_SAID];
if ((nil != saID) && ([[saID class] isSubclassOfClass: [NSData class]])) {
//[_instances addObject: aDriverInstance];
[_instanceIDs addObject: saID];
[mutableInstanceDict setObject: saID forKey: CONFIG_SAID];
} else {
if (!errorOcurred) {
[errorLog addObject: [NSNumber numberWithInt: index]];
errorOcurred = YES;
}
[errorLog addObject: [NSNumber numberWithInt: DRIVER_ERRORCODE_INSTANCEDIDNOTREPORTID]];
}

When I uncomment the addObject line above, later in the code NSFileManager throws a doesNotRespondToSelector exception, which is very odd.




On Apr 8, 2009, at 1:31 AM, Graham Cox wrote:


On 08/04/2009, at 10:23 AM, Daniel Luis dos Santos wrote:

The only thing I can think of, to see something like this is that I am probably overwriting the NSFileManager's class internal tables and therefore the message. When I comment out the assignment it all goes well.

The class that I instantiate from the bundle is handled through a protocol. The implementation is derived from an NSObject. I have considered using an NSPointerArray instead.


Show your code.

This word description is not very enlightening to anyone except you, who are familiar with the code.

Sounds like it could be an over-release problem, but without seeing the code, who knows?

--Graham



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Editor windows with title bar offscreen
  • Next by Date: Re: Editor windows with title bar offscreen
  • Previous by thread: Re: Editor windows with title bar offscreen
  • Next by thread: saving console log to a file
  • Index(es):
    • Date
    • Thread