• Overview
  • How to create a procedure in Objective C code?
  • Important notes
  • Using the UIView of a window
  • How to call Objective C classes?
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
You have the ability to type Objective C code in the iPhone/iPad applications generated with WINDEV Mobile.
This allows you to create global procedures in Objective C code.
How to create a procedure in Objective C code?
To type the code of a global procedure in Objective C code:
  1. 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.
    Caution: the procedure name must contain no accented characters.
  2. In the code editor, click the "WL" letters displayed in front of the caption of global procedure. The bar becomes light blue and the "ObjC" characters appear in front of the procedure name. The existing code is changed into comments.
For example:
  • To go back to WLanguage code, all you have to do is click "ObjC" in the procedure bar.
  • The name of Objective C procedure must contain no accented character. Otherwise, the accented characters will be deleted when switching to Objective C code.

Important notes

  • Passing parameters to an Objective C procedure is automatically done by value.
  • If the parameter is a pointer, passing parameters is done by value but you also have the ability to act on the content of the pointer in the procedure.
  • The parameters of procedures written in Objective C code must necessarily be typed with a primitive type (integer, real, string, ...). The following types are supported:
    • char
    • wchar_t
    • float
    • double
    • int
    • long
    • short
    • void
    • bool
    • BOOL
  • Avoid the comments such as "/*". The 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 onto the current UIView.
Let's see an example of Objective C code used to read 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), "")
How to call Objective C classes?
If your procedure in Objective C code is using Objective C classes:
  1. Add the imports corresponding to the Objective classes C used in the native Objective C code entered (via the "Import" keyword). We advise you to add these imports before declaring the method. For example:
  2. If the Objective C classes are found in specific libraries, these libraries must be included in the application when generating the iPhone/iPad application via the following wizard screen:
Remark: These libraries must be accessible from the PC used to generate the iPhone/iPad application.
Related Examples:
WM System 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:
- Multimedia control
- Brightness
- Volume
- Wi-Fi
- Bluetooth
- Toast
- Compass
- Accelerometer
- Camera control
- Vibration
- Notifications
- Drawing functions
- Internet
Minimum version required
  • Version 17
Click [Add] to post a comment