11. Using Yocto-RangeFinder 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.
11.1. Control of the RangeFinder function
Launch Xcode 4.2 and open the corresponding sample project provided in the directory
Examples/
Doc-GettingStarted-Yocto-RangeFinder
of the Yoctopuce library.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
#import "yocto_rangefinder.h"
#import "yocto_lightsensor.h"
#import "yocto_temperature.h"
static
void
usage
(void)
{
NSLog
(
@"usage: demo <serial_number> "
)
;
NSLog
(
@" demo <logical_name>"
)
;
NSLog
(
@" demo any (use any discovered device)"
)
;
exit
(
1
)
;
}
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-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......