
10. Using Yocto-GPS 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.
10.1. Control of the Latitude function
Launch Xcode 4.2 and open the corresponding sample project provided in the directory
Examples/
Doc-GettingStarted-Yocto-GPS
of the Yoctopuce library.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
#import "yocto_gps.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
67
Summary of Contents for Yocto-GPS
Page 1: ...Yocto GPS User s guide...
Page 2: ......
Page 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Page 10: ...4 www yoctopuce com...
Page 14: ...8 www yoctopuce com...
Page 18: ...12 www yoctopuce com...
Page 22: ...16 www yoctopuce com...
Page 38: ...32 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 54: ...48 www yoctopuce com...
Page 72: ...66 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 122: ...116 www yoctopuce com...
Page 132: ...126 www yoctopuce com...
Page 564: ...22 Characteristics 558 www yoctopuce com...
Page 565: ......
Page 566: ......