【发布时间】:2014-01-27 07:49:36
【问题描述】:
C#代码:(windows)
Assembly assembly = Assembly.LoadFrom(AssemblyPath);
System.Type[] objTypes = assembly.GetTypes();
Type libType = null;
我想在 Mac 上实现同样的效果,其中 AssemblyPath 是静态库 (libTEST.a) 或 dylib 文件的路径。在Objective-C(Mac)中可能吗? 我尝试使用 NSBundle。但我想要一些好的解决方案。
【问题讨论】:
-
你对 NSBundle 做了什么尝试,为什么它是一个“糟糕的解决方案”?那么 dlopen() 呢?在回答 stackoverflow.com/a/21338282/1187415 之前对您之前的类似问题提出了建议?
-
顺便说一句,不要重复你的问题stackoverflow.com/questions/21325604/… 并忽略给定的答案,如果答案不能解决你的问题,你可以尝试改进问题或发表评论。
-
嗨...我认为 .a(静态库)文件在 NSBundle 中不受支持。我用这个...类exampleClass; id 新实例; NSString *str = @"/Users/Desktop/libCDT.ChunkUtil.a"; NSBundle *bundleToLoad = [NSBundle bundleWithPath:str]; if (exampleClass == [bundleToLoad classNamed:@"IReaderClass"]) { newInstance = [[exampleClass alloc] init]; // [newInstance doSomething];但是 bundleToLoad 对象包含 Null 值...那该怎么办?
标签: objective-c macos .net-assembly