runtime

runtime code compilation gives error - process cannot access the file

☆樱花仙子☆ 提交于 2019-12-07 04:17:01
问题 I hava small windows app where user enter code and on button click event code is compiled at runtime. When i click button 1st time it works fine but if click same button more than once it gives error "The process cannot access the Exmaple.pdb file because it is being used by another process." . Below is the example sample code using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.CSharp; using System.CodeDom.Compiler; using System

How do I print the values of all declared properties of an NSObject?

廉价感情. 提交于 2019-12-07 03:22:52
问题 I want to override my object's description method to be able to print the values of all my declared properties. I know that I can do this by appending all the values to each other, one by one, but sometimes this is time consuming if you have a lot of properties. I was wondering if there's an easy way to do this, by getting help from the runtime powers of Objective-C? 回答1: Did you try this solution ? #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface NSObject

Command failed due to signal: Segmentation fault: 11 while emitting IR SIL function

假如想象 提交于 2019-12-06 23:55:14
问题 I want to add closure properties in the extension of UITextView so I define a closure using typealias: typealias TextViewHeightDidChangedClosure = (_ currentTextViewHeight:CGFloat)->Void extension UITextView{ func setTextViewHeightDidChanged(textViewHeightDidChanged:TextViewHeightDidChangedBlock){ objc_setAssociatedObject(self, &TextViewHeightDidChangedBlockKey, textViewHeightDidChanged, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC) } func textViewHeightDidChanged()-

Get type of an object with an object of null?

江枫思渺然 提交于 2019-12-06 20:47:49
问题 The following code does compile, but why do I get a run time exception? String b = null; System.out.println(b.getClass()); Error I get is java.lang.NullPointerException How can I get the type of the object even if it's set to null? Edit I realize there is no object present, but there still is an object b of type String. Even if it holds no object, it still has a type. How do I get at the type of an object, regardless of if it holds an object or if it does not. 回答1: When you have String b =

Target runtime Apache Tomcat v7.0 is not defined.

℡╲_俬逩灬. 提交于 2019-12-06 18:26:50
在工程目录下的.settings文件夹里,打开org.eclipse.wst.common.project.facet.core.xml文件,其内容是: <?xml version="1.0" encoding="UTF-8"?> <faceted-project> <runtime name="Apache Tomcat v7.0"/> <fixed facet="java"/> <fixed facet="jst.web"/> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.7"/> <installed facet="jst.web" version="3.0"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project> 第一种做法: 删除中间几行,只留下下面三行就行 <?xml version="1.0" encoding="UTF-8"?> <faceted-project> </faceted-project> 第二种做法: 将 <runtime name="Apache Tomcat v7.0"/> 改成你tomcat的版本比如 <runtime name="Apache Tomcat v8.0"/> 来源:

使用runtime跳转界面

三世轮回 提交于 2019-12-06 18:16:42
在开发项目中,会有这样变态的需求: 推送:根据服务端推送过来的数据规则,跳转到对应的控制器 feeds列表:不同类似的cell,可能跳转不同的控制器(嘘!产品经理是这样要求:我也不确定会跳转哪个界面哦,可能是这个又可能是那个,能给我做灵活吗?根据后台返回规则任意跳转?) 思考:wocao!这变态的需求,要拒绝他吗? switch判断呗,考虑所有跳转的因素?这不得写死我... switch () { case : break; default: break; } 我是这么个实现的(runtime是个好东西) 利用runtime动态生成对象、属性、方法这特性,我们可以先跟服务端商量好,定义跳转规则,比如要跳转到A控制器,需要传属性id、type,那么服务端返回字典给我,里面有控制器名,两个属性名跟属性值,客户端就可以根据控制器名生成对象,再用kvc给对象赋值,这样就搞定了 ---O(∩_∩)O哈哈哈 比如:根据推送规则跳转对应界面HSFeedsViewController HSFeedsViewController.h: 进入该界面需要传的属性 @interface HSFeedsViewController : UIViewController // 注:根据下面的两个属性,可以从服务器获取对应的频道列表数据 /** 频道ID */ @property (nonatomic,

runtime应用场景

ⅰ亾dé卋堺 提交于 2019-12-06 17:57:26
一、runtime简介 RunTime简称运行时。OC就是 运行时机制 ,也就是在运行时候的一些机制,其中最主要的是消息机制。对于C语言, 函数的调用在编译的时候会决定调用哪个函数 。对于OC的函数,属于 动态调用过程 ,在编译的时候并不能决定真正调用哪个函数,只有在真正运行的时候才会根据函数的名称找到对应的函数来调用。事实证明: 在编译阶段,OC可以 调用任何函数 ,即使这个函数并未实现,只要声明过就不会报错。在编译阶段,C语言调用 未实现的函数 就会报错。 二、runtime作用 1.发送消息 方法调用的本质 ,就是让对象发送消息。objc_msgSend,只有对象才能发送消息,因此以objc开头.使用 消息机制 前提,必须导入#import 消息机制简单使用 // 创建person对象 Person *p = [[Person alloc] init]; // 调用对象方法 [p eat]; // 本质:让对象发送消息 objc_msgSend(p, @selector(eat)); // 调用类方法的方式:两种 // 第一种通过类名调用 [Person eat]; // 第二种通过类对象调用 [[Person class] eat]; // 用类名调用类方法,底层会自动把类名转换成类对象调用 // 本质:让类对象发送消息 objc_msgSend([Person class

了解vue里的Runtime Only和Runtime+Compiler

纵然是瞬间 提交于 2019-12-06 16:50:43
vue中Runtime-Compiler和Runtime-only的区别: https://www.cnblogs.com/lyt0207/p/11967141.html 了解vue里的Runtime Only和Runtime+Compiler: https://www.cnblogs.com/webing/p/10733999.html 在我们使用vue-cli的时候,会提示你安装的版本 可以看到有两种版本: Runtime Only 版本 和 Runtime+Compiler 版本。 1.Runtime Only 我们在使用 Runtime Only 版本的 Vue.js 的时候,通常需要借助如 webpack 的 vue-loader 工具把 .vue 文件编译成 JavaScript,因为是在编译阶段做的,所以它只包含运行时的 Vue.js 代码,因此代码体积也会更轻量。 在将 .vue 文件编译成 JavaScript的编译过程中会将组件中的template模板编译为render函数,所以我们得到的是render函数的版本。所以运行的时候是不带编译的,编译是在离线的时候做的。 2.Runtime+Compiler 我们如果没有对代码做预编译,但又使用了 Vue 的 template 属性并传入一个字符串,则需要在客户端编译模板,如下所示: // 需要编译器的版本 new

Trait runtime type of type parameter through TypeTag when used with Existential type in Scala

删除回忆录丶 提交于 2019-12-06 16:47:11
I have trait with type parameter. To get the runtime type I use TypeTag . However, when this trait (and its classes) are used with existential type in a Collection, e.g. List or Map , TypeTag is "lost". Here is an example of standard way to use Type Tag: scala> import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala> trait Animal[T] { | def typeT()(implicit t: TypeTag[T]) = t.tpe | } defined trait Animal scala> scala> class Dog extends Animal[Int] defined class Dog scala> class Cat extends Animal[String] defined class Cat scala> scala> val dog = new Dog dog: Dog =

performance by creating new variable

狂风中的少年 提交于 2019-12-06 16:43:23
i want to write my java programm as performant as i can so i'm reducing everything to have best performance... In the programm a method will called apprx. 9million times. there i have to calculate somthing, just subtracting two integers and these are needed twice. so my question is, what is faster: initialize new integer with the result of calculation or just calculate the values twice? e.g: int result = a-b; methodToCall(result, foo, bla); otherMethod(result, bla, foo); or methodToCall(a-b, foo, bla); otherMethod(a-b, bla foo); i cant see a difference directly, but sometimes its with the