iOS if you want to implement real-time distribution, as far as I know, it's basically two ways.
1: Using LUA script, basically a lot of hands are doing this, and then with the Cocos2d-x this framework is relatively simple to use.
2: Using the dynamic library Here's what I'm talking about.
First, the realization of the idea, in the dynamic library implementation of an entry class, and the entry method, this method in the main project calls
Here are the steps to create a dynamic library:
The code is directly below.
Test interface in Dynamic library
VCOne.h
#import <UIKit/UIKit.h> @interface Vcone:uiviewcontroller@property (retain, nonatomic) NSBundle *root_bundle;// Save the path to the framework @end
Vcone.m
-(void) viewdidload{ [Super Viewdidload]; UILabel * Label1 = [[UILabel alloc] Initwithframe:cgrectmake (0, 0, Self.view.frame.size.width,)]; Label1.Text = @ "First view"; [Self.view Addsubview:label1]; Self.view.backgroundColor = [Uicolor whitecolor]; Uiimageview *image = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:[_root_bundle pathforresource:@ "Changmen" oftype:@ "JPG"]]; Image.frame = CGRectMake (+, +, +); [Self.view addsubview:image]; }
The entry classes that interact with the main project are described below.
FrameWorkStart.h
#import <Foundation/Foundation.h> @interface frameworkstart:nsobject/* * Main program and this dynamic library of the relationship hub, that is, from the "main program" to "package in the Dynamic Library program" The entry method */-(void) Startwithobject: (ID) object Withbundle: (NSBundle *) bundle; @end
Frameworkstart.m
#import "FrameWorkStart.h" #import "VCOne.h" @implementation frameworkstart-(void) Startwithobject: (ID) object Withbundle: (NSBundle *) bundle{*/ * Initialize First controller * The focus here is on the loading of the resource files. Usually we don't really care about bundles when we initialize: this parameter , in fact, we use the image, Xib and other resource files are obtained within the program, that is, we commonly used [NSBundle Mainbundle] in the acquisition, so-called nsbundle is essentially a path, mainbundle points to the. App. and if we don't specify bundles, we'll look for resources from the. App path by default. However, it is obvious that our dynamic library is placed under the "main program" document file, so the resource file is not available in [NSBundle Mainbundle], so here we need to specify the bundle parameters, This is also the meaning of the path passing the framework */ Vcone *vcone = [[Vcone alloc] init]; Vcone.root_bundle = bundle; Conversion passed over the Maincon parameter, implement interface jump uiviewcontroller *viewcon = (Uiviewcontroller *) object; [Viewcon presentviewcontroller:vcone animated:yes completion:^{ NSLog (@ "Jump to dynamic Update module success!");} ]; }
Here is the main project, of course, the normal iOS project that was created
Viewcontroller.m
#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) viewdidload {[Super V Iewdidload]; Additional setup after loading the view, typically from a nib. UIButton * btn = [UIButton buttonwithtype:uibuttontyperoundedrect]; Btn.frame = CGRectMake (30, 30, 100, 50); [BTN settitle:@ "Test dynamic Library" Forstate:uicontrolstatenormal]; [Btn addtarget:self Action: @selector (Test) forcontrolevents:uicontroleventtouchupinside]; [Self.view ADDSUBVIEW:BTN]; }-(void) test{nsarray* paths = Nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask,yes); NSString *documentdirectory = nil; if ([Paths count]! = 0) documentdirectory = [Paths objectatindex:0]; NSLog (@ "documentdirectory =%@", documentdirectory); Stitching the framework path we put into document nsstring *libname = @ "Test1.framework"; NSString *destlibpath = [Documentdirectory stringbyappendingpathcomponent:libname]; Judging if there's no such file exists.Jump directly out of nsfilemanager *manager = [Nsfilemanager Defaultmanager]; if (![ Manager Fileexistsatpath:destlibpath]) {NSLog (@ "there ' t has the file"); Return }//Copy into program Nserror *error = nil; Load mode two: Use nsbundle load dynamic library NSBundle *frameworkbundle = [NSBundle Bundlewithpath:destlibpath]; if (frameworkbundle && [frameworkbundle load]) {NSLog (@ "Bundle load framework success."); else {NSLog (@ "Bundle load Framework err:%@", error); Return }/* * Read the class *frameworkstart as a dynamic library in nsclassfromstring mode */Class Pacteraclass = Nsclassfromstring (@ " Frameworkstart "); if (!pacteraclass) {NSLog (@ "Unable to get Testdylib class"); Return }/* * Initialization takes the form of Alloc init in the form of the same, the direct use of the Pacteraframework class initialization is also incorrect * pass-(ID) Performselector: (SEL) Aselector withobject: (ID) object1 withobject: (ID) object2; Method calls the Ingress method (Startwithobject:withbundle:) and passes the parameters (withobject:self WithoBject:frameworkbundle) */NSObject *pacteraobject = [Pacteraclass new]; [Pacteraobject performselector: @selector (startwithobject:withbundle:) withobject:self Withobject:frameworkbundle] ; }Compile the project of the dynamic library and put it into the main projectdocument in the directory
This is recorded if the compiled static library is found.
code example: http://download.csdn.net/detail/qqmcy/8569901
iOS live version, dynamic library mode is not available in the App Store