And if you have a constant NSString in the binary, and that string is 
referenced anywhere in the application, then unloading the binary will crash 
the next time that constant string is referenced.

It is *really* hard to make a properly un-loadable bundle and generally 
in-advised, as the advantages tend to be non-existant compared to the effort 
required.

And also, if you are loading the bundle, then again there is little need to do 
actual class walking as such, since you are in control of the bundle and its 
formatting. Require the bundles to tell you the classes that are SKFormat 
subclasses in the bundle’s property list and only use those.

> On Dec 15, 2014, at 10:19 AM, Maxthon Chan <m...@maxchan.info> wrote:
> 
> My current design is that the main code is never possible of holding strong 
> references to plugin code for extended periods. Main code keeps an eye on a 
> folder and whenever a new bundle is dropped in it is loaded, and whenever a 
> bundle is removed code is unloaded. Class walking is used to detect the 
> classes loaded. Also, SKFormat does not have any instance methods, only class 
> methods, just to prevent any autorelease pool holding onto it.
> 
>> On Dec 16, 2014, at 02:09, David Duncan <david.dun...@apple.com 
>> <mailto:david.dun...@apple.com>> wrote:
>> 
>> 
>>> On Dec 15, 2014, at 9:59 AM, Maxthon Chan <m...@maxchan.info 
>>> <mailto:m...@maxchan.info>> wrote:
>>> 
>>> I do own the entire SubtitleKit framework but the problem is I want it 
>>> allow loading and unloading format plugins without restarting the host 
>>> application. This library only have one internal parser for basic SubRip 
>>> format and plugins are used for styled SubRip, Multi-track SubRip, 
>>> SubStation Alpha and other formats.
>> 
>> 
>> You can post a notification when a format plugin loads (aka registers 
>> itself) for those that are interested in knowing that new formats are 
>> available.
>> 
>> As for unloading, unloading Objective-C code is generally considered 
>> difficult at best, especially since it is often hard to control whom is 
>> referencing any content in the binary (and where once you’ve unloaded that 
>> bundle anyone referencing that code will crash).
>> 
>> Overall the simplest solution seems to be that your SubtitleKit framework 
>> provides a method for loading these format plugins and does the registration 
>> itself. Your users always use that method and you don’t have any of these 
>> problems.
>> --
>> David Duncan
>> 
> 

--
David Duncan

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to