|
|
|
|
|
- Overview
- How to create a procedure in Objective-C?
- Important notes
- Using the UIView of a window
- How to call Objective-C classes?
You can use Objective-C code in iPhone/iPad applications generated with WINDEV Mobile. This allows you to create global procedures in Objective-C . How to create a procedure in Objective-C? To write a global procedure in Objective-C: - Create a new global procedure (via "New global procedure" in the context menu of sets of procedures in the "Project explorer" pane). Specify the name of this procedure.
Warning: the procedure name must not contain accented characters.. - The procedure is created in the code editor.
- In the header of the procedure, click "WL" to change the type of code.
- In the list that opens, select "ObjC".
- The header becomes light blue and "ObjC" appears to the left of the procedure name. The existing code is commented out.
Remarks: - To switch back to WLanguage code, simply click "ObjC" in the procedure header and select "WLanguage".
- The name of the Objective-C procedure must not contain accents. Otherwise, accents are removed when switching to Objective-C code.
Important notes - In Objective-C procedures, parameters are automatically passed by value.
- If the parameter is a pointer, parameters are passed by value but can still make changes to the content of the pointer in the procedure.
- The parameters of procedures written in Objective-C must be of a primitive type (integer, real, string, etc.). The following types are supported:
- char
- wchar_t
- float
- double
- int
- long
- short
- void
- bool
- BOOL
- Avoid commenting with "/*". WLanguage comments ("//") are supported.
Using the UIView of a window The UIView of a window cannot be used directly. However, Handle is used to get a pointer to the current UIView. Here is an example of Objective-C code to play a video: #import <MediaPlayer/MediaPlayer.h>
void PlayVideo(void* currentView, NSString* VideoURL) { MPMoviePlayerController *moviePlayer; NSURL *movieURL; UIView *tmpView = (UIView*)currentView; movieURL = [NSURL URLWithString:VideoURL]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; [tmpView addSubview:moviePlayer.view]; moviePlayer.fullscreen = YES; [moviePlayer play]; } and the corresponding call in WLanguage: PlayVideo(Handle(MyWindow, HandleUIViewController), "http://myvideo.com/myvideo.mp4")
How to call Objective-C classes? If your procedure in Objective-C uses Objective-C classes: - Add the imports corresponding to the Objective classes C used in the native Objective-C code (via the "Import" keyword). We advise you to add these imports before declaring the method. For example:
- If the Objective-C classes are in specific libraries, include those libraries in the following step of the iPhone/iPad application generation wizard:
Note: These libraries must be accessible from the PC used to generate the iPhone/iPad application..
Related Examples:
|
Cross-platform examples (WINDEV Mobile): WM System
[ + ] This application is an example of some of the features of WINDEV Mobile available for Android/iOS. The following system functions are used: - NFC - Multimedia control - Brightness - Volume - Wi-Fi - Bluetooth - Toast - Compass - Accelerometer - Camera control - LED - Vibration - Notifications - Drawing functions - Internet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|