PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • How to create a procedure in Objective C code?
  • Important notes
  • Using the UIView of a window
  • How to call Objective C classes?
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
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" from the popup 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:
becomes:
Notes:
  • 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), "http://myvideo.com/myvideo.mp4")
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:
Note: These libraries must be accessible from the PC used to generate the iPhone/iPad application.
Related Examples:
iOS System iPhone/iPad (WINDEV Mobile): iOS System
[ + ] This application is an example presenting the use of various features.
The features are as follows:
- Playing videos
- Trace in the logs
- Slider
- Popup control
- Hourglass
...
Minimum required version
  • Version 17
Comments
Media Player SDK
Could you please attach the SDK used for this example (MediaPlayer) so i can use this as a sample? Thank you!
Denny
Nov. 27 2017