Help / Developing for iOS (iPhone / iPad)
  • Overview
  • How to create a procedure in Objective C?
  • 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 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:
  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. The procedure is created in the code editor.
  3. In the header of the procedure, click "WL" to change the type of code.
  4. In the list that opens, select "ObjC".
  5. The header becomes light blue and "ObjC" appears to the left of the procedure name. The existing code is commented out.
  • 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), "")
How to call Objective C classes?
If your procedure in Objective C uses Objective C classes:
  1. 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:
  2. If the Objective C classes are in specific libraries, include those libraries in the following step of the iPhone/iPad application generation wizard:
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

Last update: 06/23/2023

Send a report | Local help