12. Using Yocto-Display with Objective-C
Objective-C is language of choice for programming on Mac OS X, due to its integration with the
Cocoa framework. In order to use the Objective-C library, you need XCode version 4.2 (earlier
versions will not work), available freely when you run Lion. If you are still under Snow Leopard, you
need to be registered as Apple developer to be able to download XCode 4.2. The Yoctopuce library
is ARC compatible. You can therefore implement your projects either using the traditional
retain /
release
method, or using the
Automatic Reference Counting
.
Yoctopuce Objective-C libraries
1
are integrally provided as source files. A section of the low-level
library is written in pure C, but you should not need to interact directly with it: everything was done to
ensure the simplest possible interaction from Objective-C.
You will soon notice that the Objective-C API defines many functions which return objects. You do
not need to deallocate these objects yourself, the API does it automatically at the end of the
application.
In order to keep them simple, all the examples provided in this documentation are console
applications. Naturally, the libraries function in a strictly identical manner if you integrate them in an
application with a graphical interface. You can find on Yoctopuce blog a detailed example
2
with video
shots showing how to integrate the library into your projects.
12.1. Control of the Display function
Launch Xcode 4.2 and open the corresponding sample project provided in the directory
Examples/
Doc-GettingStarted-Yocto-Display
of the Yoctopuce library.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
#import "yocto_display.h"
static
void
usage
(
void
)
{
NSLog
(
@"usage: demo <serial_number> "
)
;
NSLog
(
@" demo <logical_name>"
)
;
NSLog
(
@" demo any (use any discovered device)"
)
;
exit
(
1
)
;
}
int
main
(
int
argc,
const
char
*
argv
[])
{
1
www.yoctopuce.com/EN/libraries.php
2
www.yoctopuce.com/EN/article/new-objective-c-library-for-mac-os-x
www.yoctopuce.com
65
Содержание Yocto-Display
Страница 1: ...Yocto Display User Manual...
Страница 2: ......
Страница 40: ...34 www yoctopuce com...
Страница 52: ...46 www yoctopuce com...
Страница 84: ...78 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...22 High level API Reference 152 www yoctopuce com On failure throws an exception or returns a negative error code...
Страница 422: ...416 www yoctopuce com...
Страница 424: ...24 Characteristics 418 www yoctopuce com...