Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-22-2011, 10:13 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default passing multiple parameters into a function

In the calling function I have the following code:

Code:
           
  {

           printf("-----*---*-----Distance %f, Lat: %f, Lng: %f", myDistance, myLat, myLng);
                           printf("\n");  
            
            [self drawOnMap:myDistance Lat:myLat Lng:myLng];
        
    }
In the function called:
Code:
 
-(void)drawOnMap:(float)distance Lat:(float)lat Lng:(float)lng
 {
     
                printf("===*==*====Distance %f, Lat: %f, Lng: %f", distance, lat, lng);
                printf("\n-----*---*-----\n");  
}

But the output is as follows:

-----*---*-----Distance 60.500000, Lat: -33.875900, Lng: 151.206314
===*==*====Distance 0.000000, Lat: 3.222656, Lng: -0.000000


What have I done wrong?
TelTikky is offline   Reply With Quote
Old 11-22-2011, 11:14 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Doncaster UK
Posts: 120
acegames is on a distinguished road
Default

Have you declared your function in the .h ?
acegames is offline   Reply With Quote
Old 11-22-2011, 11:59 AM   #3 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Are any of these names:

Code:
-(void)drawOnMap:(float)distance Lat:(float)lat Lng:(float)lng
...declared individually in the .h file?
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 11-22-2011, 07:28 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

Quote:
Originally Posted by acegames View Post
Have you declared your function in the .h ?
No. Didn't think it was necessary.
TelTikky is offline   Reply With Quote
Old 11-22-2011, 07:28 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Are any of these names:

Code:
-(void)drawOnMap:(float)distance Lat:(float)lat Lng:(float)lng
...declared individually in the .h file?
No, I double checked. None of them were declared individually in the .h file.
TelTikky is offline   Reply With Quote
Old 11-22-2011, 08:25 PM   #6 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by TelTikky View Post
No, I double checked. None of them were declared individually in the .h file.
Are you getting your coordinates from a CLLocationManager? CLLocationCoordinate2D is a struct containing fields that are typedef'ed as doubles, not floats. Could you be losing some info in the conversion from double to float?

Ed
ebender001 is offline   Reply With Quote
Old 11-22-2011, 10:53 PM   #7 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

Quote:
Originally Posted by ebender001 View Post
Are you getting your coordinates from a CLLocationManager? CLLocationCoordinate2D is a struct containing fields that are typedef'ed as doubles, not floats. Could you be losing some info in the conversion from double to float?

Ed
Cool, you are right. Changed everything to double solved the problem.

Thanks.

Just a side note, passing everything in NSString* will do the trick too ...
TelTikky is offline   Reply With Quote
Old 11-23-2011, 08:44 AM   #8 (permalink)
Registered Member
 
ebender001's Avatar
 
Join Date: Mar 2010
Location: Missouri
Age: 57
Posts: 70
ebender001 is on a distinguished road
Default

Quote:
Originally Posted by TelTikky View Post
Cool, you are right. Changed everything to double solved the problem.

Thanks.

Just a side note, passing everything in NSString* will do the trick too ...
Glad it worked and thanks for the tip.
Ed
ebender001 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 399
16 members and 383 guests
7twenty7, chiataytuday, Clouds, dedeys78, Duncan C, e2applets, EvilElf, iekei, ipodphone, jeroenkeij, leostc, mbadegree, Murphy, QuantumDoja, sacha1996, Sami Gh
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:34 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0