////WJRUNTIME.M//Runtimeskip////Created by Tqh on 15/9/8.//Copyright (c) 2015 TQH. All rights reserved.//#import "WJRuntime.h"#import<objc/runtime.h>@implementationWjruntime//Runtime Jump+ (void) Runtimepush: (NSString *) vcname dic: (nsdictionary *) DiC nav: (Uinavigationcontroller *) Nav {//class name (object name)NSString*class=Vcname; Const Char*classname = [classcstringusingencoding:nsasciistringencoding]; Class Newclass=Objc_getclass (className); if(!Newclass) { //Create a classClass superclass = [NSObjectclass]; Newclass= Objc_allocateclasspair (superclass, ClassName,0); //register the class that you createdObjc_registerclasspair (Newclass); } //Create the object (write here can be random page jump) IDInstance =[[Newclass alloc] init]; //here is the value--------------[dic enumeratekeysandobjectsusingblock:^(IDKeyIDobj, BOOL *stop) { if([self checkisexistpropertywithinstance:instance verifypropertyname:key]) {//KVC Assigning a value to a property[instance setvalue:obj Forkey:key]; }Else{NSLog (@"properties that do not contain key=%@", key); } }]; [Nav pushviewcontroller:instance Animated:yes]; }/** * Detects if the object has this attribute*/+ (BOOL) Checkisexistpropertywithinstance: (ID) Instance Verifypropertyname: (NSString *) verifypropertyname{unsignedintOutcount, I; //gets the list of properties in the objectobjc_property_t * Properties =Class_copypropertylist ([instanceclass], &outcount); for(i =0; i < Outcount; i++) {objc_property_t property=Properties[i]; //property names into stringsNSString *propertyname =[[NSString alloc] Initwithcstring:property_getname (property) encoding:nsutf8stringencoding]; //determine if the property exists if([PropertyName isequaltostring:verifypropertyname]) {free (properties); returnYES; }} free (properties); returnNO;}@end
Ios-runtime-is pushed to any controller based on the class name and implements the property pass value