Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 17, 2008, 04:56 PM   #1
orangebeard78
macrumors newbie
 
Join Date: Mar 2008
Core Location Example

Does anyone have any examples they would like to share regarding the
Core Location framework in the SDK? I am in desperate need of help.
The only code that I can find is what is available on the iPhone Dev
website, which isn't much. I tried to implement the code into my
program but I get a error: "locationManager undeclared (first use in
this funciton".

Here is the code...
Code:
#import "MyLocationGetter.h"
#import <CoreLocation/CoreLocation.h>

@implementation MyLocationGetter

- (void)startUpdates
{
    // Create the location manager if this object does not
    // already have one.

   //ERROR is HERE!!!
    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    locationManager.distanceFilter = 1000;  // 1 kilometer
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
    [locationManager startUpdatingLocation];

}

// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
    fromLocation:(CLLocation *)oldLocation
{
    // Disable future updates to save power.
    [manager stopUpdatingLocation];

     printf("latitude %+.6f, longitude %+.6f\n",
            newLocation.coordinate.latitude,
            newLocation.coordinate.longitude);

}

@end
orangebeard78 is offline   0 Reply With Quote
Old Mar 17, 2008, 05:01 PM   #2
admanimal
macrumors 68040
 
Join Date: Apr 2005
Is locationManager declared as a property of MyLocationGetter in your header file? If not, it is undeclared in the startUpdates method and that is why you are getting that error.

Last edited by admanimal; Mar 17, 2008 at 08:39 PM.
admanimal is offline   0 Reply With Quote
Old Mar 17, 2008, 05:10 PM   #3
orangebeard78
Thread Starter
macrumors newbie
 
Join Date: Mar 2008
thanks admanimal for the reply.

it is not declared as a property.

newbie question...what should I declare it as? and how to declare it? not real comfortable with Ojective-C yet if you couldn't already tell
orangebeard78 is offline   0 Reply With Quote
Old Apr 1, 2008, 08:07 AM   #4
CMoebius
macrumors newbie
 
Join Date: Apr 2008
Location: Tampa Bay, FL
Send a message via Yahoo to CMoebius
init?

I am struggling with getting the Core Location stuff working also. Does anyone know if it works in the emulator?

Chris

Last edited by CMoebius; Apr 1, 2008 at 08:20 AM.
CMoebius is offline   0 Reply With Quote
Old Apr 1, 2008, 10:29 AM   #5
himansk
macrumors regular
 
Join Date: Oct 2006
Core location does not work in the simulator, you need to attach the iphone to test it.
__________________
retinaMacbookPro 2.6GHz, 16GB RAM, 256GB SSD
iPhone4 32GB
himansk is offline   0 Reply With Quote
Old Apr 1, 2008, 10:10 PM   #6
CMoebius
macrumors newbie
 
Join Date: Apr 2008
Location: Tampa Bay, FL
Send a message via Yahoo to CMoebius
Attach an iPhone?

Only if you are one of the lucky ones to be accepted into the Developer Program, right? You have to have the 2.0 beta on the phone to be able to transfer apps to it, right?
CMoebius is offline   0 Reply With Quote
Old Apr 1, 2008, 11:31 PM   #7
admanimal
macrumors 68040
 
Join Date: Apr 2005
Quote:
Originally Posted by CMoebius View Post
Only if you are one of the lucky ones to be accepted into the Developer Program, right? You have to have the 2.0 beta on the phone to be able to transfer apps to it, right?
That is correct.
admanimal is offline   0 Reply With Quote
Old Apr 2, 2008, 09:53 AM   #8
himansk
macrumors regular
 
Join Date: Oct 2006
Quote:
Originally Posted by CMoebius View Post
Only if you are one of the lucky ones to be accepted into the Developer Program, right? You have to have the 2.0 beta on the phone to be able to transfer apps to it, right?
Yup, I have the access to 2.0, but I havent gotten around to experiment with core location yet...
__________________
retinaMacbookPro 2.6GHz, 16GB RAM, 256GB SSD
iPhone4 32GB
himansk is offline   0 Reply With Quote
Old Apr 12, 2008, 08:35 PM   #9
nujjus
macrumors newbie
 
Join Date: Apr 2008
Hmm, did this work for you? For some reason I get linking errors:

"_kCLLocationAccuracyKilometer", referenced from:
_kCLLocationAccuracyKilmoeter$non_lazy_ptr in MyLocationGetter.o

and

".objc_class_name_CLLocationManager", referened from:
literal-pointer@__OBJC@__cls_refs@CLLocationManager in MyLocationGetter.o
symbol(s) not found
collect2: ld returned 1 exit status
nujjus is offline   0 Reply With Quote
Old Apr 13, 2008, 04:55 PM   #10
CMoebius
macrumors newbie
 
Join Date: Apr 2008
Location: Tampa Bay, FL
Send a message via Yahoo to CMoebius
Quote:
Originally Posted by nujjus View Post
Hmm, did this work for you? For some reason I get linking errors:

"_kCLLocationAccuracyKilometer", referenced from:
_kCLLocationAccuracyKilmoeter$non_lazy_ptr in MyLocationGetter.o

and

".objc_class_name_CLLocationManager", referened from:
literal-pointer@__OBJC@__cls_refs@CLLocationManager in MyLocationGetter.o
symbol(s) not found
collect2: ld returned 1 exit status
You have to add the core location framework to your project. If you right-click on the name of your project in the groups pane and choose add existing framework (can't remember the exact wording) it should build.

Hope this helps.
CMoebius is offline   0 Reply With Quote
Old Apr 18, 2008, 12:50 AM   #11
sefudiere
macrumors newbie
 
Join Date: Oct 2007
And where would this framework be located? I tried adding from /System/Library/frameworks and i could not find a CoreLocation.framework there or anything remotely close to it.

Thanks..
sefudiere is offline   0 Reply With Quote
Old Apr 19, 2008, 03:00 PM   #12
CMoebius
macrumors newbie
 
Join Date: Apr 2008
Location: Tampa Bay, FL
Send a message via Yahoo to CMoebius
The core location framework is...

Quote:
Originally Posted by sefudiere View Post
And where would this framework be located? I tried adding from /System/Library/frameworks and i could not find a CoreLocation.framework there or anything remotely close to it.

Thanks..
in this folder on my machine:

Macintosh HD\Developer\Platforms\iPhoneSimulator.platform\Developer\SDKs\iPhoneSimulator2.0.sdk\System\Library \Frameworks

and it's name is CoreLocation.framework

I guess you could search your machine for this filename also.

Hope this helps.
CMoebius is offline   0 Reply With Quote
Old Aug 24, 2008, 11:17 PM   #13
newy
macrumors newbie
 
Join Date: Aug 2008
CoreLocation linking error

Quote:
Originally Posted by nujjus View Post
Hmm, did this work for you? For some reason I get linking errors:

"_kCLLocationAccuracyKilometer", referenced from:
_kCLLocationAccuracyKilmoeter$non_lazy_ptr in MyLocationGetter.o

and

".objc_class_name_CLLocationManager", referened from:
literal-pointer@__OBJC@__cls_refs@CLLocationManager in MyLocationGetter.o
symbol(s) not found
collect2: ld returned 1 exit status
I am getting this same error and am SO frustrated... I've tried dragging the CoreLocation framework from the LocateMe sample and other examples that work and it still fails when I put it into my own project. How do you fix this?!!?!?
newy is offline   0 Reply With Quote
Old Aug 25, 2008, 08:19 AM   #14
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by orangebeard78 View Post
I tried to implement the code into my
program but I get a error: "locationManager undeclared (first use in
this funciton".
1. The iPhone SDK is under NDA. Anyone who publishes examples how to use any iPhone-specific Cocoa classes is in breach of their NDA, which could have all kinds of unpleasant consequences.

2. When the compiler says "xxx undeclared (first use in this function)" it means that you haven't declared xxx anywhere, at least not somewhere where the compiler could find it. This is basic Objective-C programming and has nothing to do with the iPhone at all. What is "locationManager" supposed to be? If it is supposed to be a static or global variable, then you better define it as a static or global variable.
gnasher729 is offline   0 Reply With Quote
Old Aug 25, 2008, 10:19 AM   #15
liptonlover
macrumors 6502a
 
Join Date: Mar 2008
that stupid NDA... I gave up on learning iphone specific stuff for now because of it. I believe you can use a hooked up iphone as a testing device without getting into the $99 developer license. The app just won't stay on the device.
__________________
Failure is not an option. It comes bundled with Windows.
Writing portfolio
liptonlover is offline   0 Reply With Quote
Old Aug 27, 2008, 04:19 AM   #16
Palad1
macrumors 6502a
 
Palad1's Avatar
 
Join Date: Feb 2004
Location: London, UK
First rule of iPhone SDK...

Last edited by Palad1; Aug 27, 2008 at 05:03 AM. Reason: I'm going to try and keep MR rant-free...
Palad1 is offline   0 Reply With Quote
Old Aug 27, 2008, 04:41 AM   #17
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Quote:
Originally Posted by liptonlover View Post
that stupid NDA... I gave up on learning iphone specific stuff for now because of it. I believe you can use a hooked up iphone as a testing device without getting into the $99 developer license. The app just won't stay on the device.
I believe otherwise: I certainly couldn't until I got my provisioning profile...
robbieduncan is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iBeacons and Core Location mrTortex iPhone/iPad Programming 3 Nov 23, 2013 07:21 AM
iPhone: FakeLocation\Location Spoofer\Netshade - Any allow pinpoint location set? shenan1982 Jailbreaks and iOS Hacks 10 Mar 28, 2013 08:54 AM
Mid 2007 iMac CPU upgrade: Core 2 Duo to Core 2 Extreme or Core 2 Quad Hexley iMac 2 Dec 9, 2012 09:56 AM
problem when app launched in Core Location Event Narendar Singh iPhone/iPad Programming 2 Nov 1, 2012 02:04 AM
One core, dual core, quad core? Whats A6? Sensamic iPhone 49 Sep 13, 2012 03:59 PM

Forum Jump

All times are GMT -5. The time now is 05:34 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC