runtime

Objective-C-Runtime Bug When Naming a Superclass “Message”

一笑奈何 提交于 2019-12-20 01:45:18
问题 I have the following class hierachy: @interface Message : NSObject {} @end @implementation Message - (void) dealloc { // I won't be called [super dealloc]; } @end @interface FooMessage : Message {} @end @implementation FooMessage - (void) dealloc { // should call Message - dealloc [super dealloc]; } @end And the following unit test: - (void) test { FooMessage* msg = [[FooMessage alloc] init]; [msg release]; } The test will always fail with EXC_BAD_INSTRUCTION. FooMessage calls it's super

深入了解Dynamic & DLR(一)

别来无恙 提交于 2019-12-20 00:48:47
本文主要谈谈个人对DLR的认识和学习,希望能和大家一起探讨下。 主要内容: DLR在面向服务设计的必要性 dynamic类型 DLR ScriptRuntime DynamicObject & ExpandoObject 1.DLR在面向服务设计中的必要性 题外前因话:商业业务环境的变更总是伴随着技术的变革。近来面向服务编程SOA的兴起是一种必然,涉及以下几个因素: 其一商业经营需要及时快速的调整; 其二在快速调整的同时,无需额外的开销,无需重构代码,重新发布平台; 其三商业平台的扩展性和稳定性; 其四商业平台维护费用; SOA在业务平台整体上进行布局整合,发布服务契约,数据契约等等,那么涉及细颗粒度的操作,比如说商场需要实时对销货策略进行变更。1.客户类别不同打折销售,2.节假日不同打折,3.不同的商品类别折扣不同,4.促销商品折扣,5.销售额满多少,折扣多少等等,我们需要以后对销售策略进行实时维护,能新增,删除,修改。在当前我们可能通过App.config文件设置不同参数值来满足我们的业务需求,或者通过dll反射的方式来选择不同销售策略。但这些能灵活配置的有限,无法满足日益增长复杂业务逻辑的变化。对此我们需要这些业务需求能够“动态加载,动态注入”,最好是脚本语言,不需要进行第二次编译,现有的Framework能够自动解析执行。 C#仍是一种静态的类型化语言,无法完美支持动态编程

How to programmatically construct components at runtime using C++ Builder?

房东的猫 提交于 2019-12-19 19:55:31
问题 Very basic C++ Builder question. I want to create a TButton at runtime. I would have thought that the following code would do it, but I see no button on the form: __fastcall TForm2::TForm2(TComponent* Owner): TForm(Owner) { TButton* b = new TButton(this); b->Height = 100; b->Width = 100; b->Left = 0; b->Top = 0; b->Caption = "Testing"; b->Visible = true; b->Enabled = true; } Thanks for any help! 回答1: You need to set the button's Parent (the surface it displays on): b->Parent = this; 来源: https

How to check existence of a program in the path

不羁的心 提交于 2019-12-19 12:37:13
问题 I'm writing a program in scala which call: Runtime.getRuntime().exec( "svn ..." ) I want to check if "svn" is available from the commandline (ie. it is reachable in the PATH). How can I do this ? PS: My program is designed to be run on windows 回答1: I'm no scala programmer, but what I would do in any language, is to execute something like ' svn help ' just to check the return code (0 or 1) of the exec method... if it fails the svn is not in the path :P Runtime rt = Runtime.getRuntime();

Running PHP from Java

纵饮孤独 提交于 2019-12-19 12:06:30
问题 I am trying to run the following from java file. I am trying to display the php version and later will change to run php files. Process p = Runtime.getRuntime().exec("cmd /C PHP/php.exe -v"); BufferedReader in = new BufferedReader(new InputStreamReader( p.getInputStream())); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); } When I run the program, there is no error. but console is not displaying anything :( Thank you. 回答1: You have to wait for the

How can we handle enable/disable background audio abilities at runtime on iOS devices?

喜你入骨 提交于 2019-12-19 12:01:41
问题 I know how to set up my iOS application to make it playing audio in background (= when another application is used on the iOS device) using the plist. Some applications like: - BLOOM - some radio players provides a basic UISwitch to enable or disable this behavior. Any ideas about how to do that ? 回答1: Have an iVar of type UIBackgroundTaskIdentifier in the main class that handles audio playing code, initialize this with beginBackgroundTaskWithExpirationHandler.... method before starting the

How can we handle enable/disable background audio abilities at runtime on iOS devices?

二次信任 提交于 2019-12-19 12:00:07
问题 I know how to set up my iOS application to make it playing audio in background (= when another application is used on the iOS device) using the plist. Some applications like: - BLOOM - some radio players provides a basic UISwitch to enable or disable this behavior. Any ideas about how to do that ? 回答1: Have an iVar of type UIBackgroundTaskIdentifier in the main class that handles audio playing code, initialize this with beginBackgroundTaskWithExpirationHandler.... method before starting the

Executing external program in java and passing commands

孤街浪徒 提交于 2019-12-19 11:15:33
问题 I have this chess engine Rybka.exe, that i have to execute in java Here is an example how you run Rybka: Once you clicked on it, console opens and waits for input. So then you enter "uci" and you press enter and you wait for it to load (approx. 1 sec) and then you have to enter a few more lines as options and stuff. The problem is that I don't know how to pass those commands from java to Rybka. The fact is that those commands need to be entered one at a time, because you have to wait for some

Change language on runtime in Android

可紊 提交于 2019-12-19 10:40:32
问题 I have to change the language on runtime in Android (yes, I know that this is not a good behaviour, but this is a requirement...). So I have a basic class, from which every activity extends. This class has the following function: public static void changeLanguage(Context context) { Resources res = context.getResources(); /* * Change locale settings in the app. */ DisplayMetrics dm = res.getDisplayMetrics(); /* * Store and load data in this preferences */ android.content.res.Configuration conf

Convert string to code at run time c++

巧了我就是萌 提交于 2019-12-19 07:52:26
问题 I am generating If Else Expressions of the following format If(X > 10) Then Fly = True Else Fly = False If(X > 9) Then Fly = True Else Fly = False If(X > 8) Then Fly = True Else Fly = False If(X > 7) Then Fly = True Else Fly = False If(X > 6) Then Fly = True Else Fly = False I was Wondering Can i execute this expressions at run time? I don't know if my question is clear. I'll add an example String = ""; for(int i = 0; i < n; i++) { string ="if(x > 10){Fly = true;} else {Fly = False;}";