How to get Latitude,Longitude of two cities and Calculate Distance in iphone

import Framework
CoreLocation.framework
MapKit.framework

 
//————————————————————————
#import “ViewController.h”
#import <MapKit/MapKit.h>
 
NSMutableArray *citynamearray;
NSMutableArray *latarray,*longarray;
 

//————————————————————————
#import “ViewController.m”
– (void)viewDidLoad
{
[super viewDidLoad];
citynamearray = [[NSMutableArray alloc]init];
 
latarray = [[NSMutableArray alloc]init];
longarray =[[NSMutableArray alloc]init];
 
[citynamearray addObject:CityName1];
[citynamearray addObject:CityName2];
 
for (int i = 0; i < [citynamearray count]; i++)
{
NSString *urlpath = [NSString stringWithFormat:@”http://maps.googleapis.com/maps/api/geocode/json?address=%@&sensor=true”,[citynamearray objectAtIndex:i]];
 
NSURL *path = [NSURL URLWithString:urlpath];
NSData* data = [NSData dataWithContentsOfURL:path];
[self performSelectorOnMainThread:@selector(fetchedLatLong:) withObject:data waitUntilDone:YES];
}
 
[self CalculateDistance :[latarray objectAtIndex:0]  :[longarray objectAtIndex:0]  :[latarray objectAtIndex:1] :[longarray objectAtIndex:1]];
}
 
– (void)fetchedLatLong:(NSData *)responseData
{
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
 
NSArray *items = [json objectForKey:@”results”];
 
NSArray *items1 = [items valueForKey:@”geometry”];
NSArray *items2 = [items1 valueForKey:@”location”];
 
NSString *latlongstr = [NSString stringWithFormat:@”%@”,[items2 objectAtIndex:0]];
latlongstr = [latlongstr stringByReplacingOccurrencesOfString:@” ” withString:@””];
latlongstr = [latlongstr stringByReplacingOccurrencesOfString:@”n” withString:@””];
latlongstr = [latlongstr stringByReplacingOccurrencesOfString:@”}” withString:@””];
 
NSArray *latlngarr = [latlongstr componentsSeparatedByString:@”;”];
NSString *lat = [NSString stringWithFormat:@”%@”,[latlngarr objectAtIndex:0]];
lat = [lat stringByReplacingOccurrencesOfString:@”{lat=”” withString:@””];
lat = [lat stringByReplacingOccurrencesOfString:@””” withString:@””];
 
NSString *lng = [NSString stringWithFormat:@”%@”,[latlngarr objectAtIndex:1]];
lng = [lng stringByReplacingOccurrencesOfString:@”lng=”” withString:@””];
lng = [lng stringByReplacingOccurrencesOfString:@””” withString:@””];
 
[latarray addObject:lat];
[longarray addObject:lng];
 
NSLog(@”Lat %@ Long%@=”,latarray,longarray);
}
 
– (void) CalculateDistance : (NSString *)a : (NSString *)b :(NSString *)c :(NSString *)d
{
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:[a floatValue] longitude:[b floatValue]];
CLLocation *location2 = [[CLLocation alloc] initWithLatitude:[c floatValue] longitude:[d floatValue]];
 
NSString *Distance = [NSString stringWithFormat:@”Distance :%f meters”,[location1 distanceFromLocation:location2] * 0.001];
NSLog(@”Distance =%@”,Distance);
 
[location1 release];
[location2 release];
}

How to manage application when orientation changes?

The problem is that when you rotate the device then

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

Method gets called but when you go to the next screen then this method does not get called. if you rotate your device again then that method gets called.

So if you want to change next screen orientation as device current orientation, then check the device’s current orientation with in viewDidLoad() method or ViewWillApper() method. Then according to that set your current view.

For finding touch location on screen in cocos2d (ios)

Try This code and get touch location in cocos2d (ios)


 - (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
         {
             UITouch *myTouch = [touches anyObject];
             CGPoint location = [myTouch locationInView:[myTouch view]];
             location = [[CCDirector sharedDirector] convertToGL:location];
         }

Welcome

Welcome to Nanostuffs Blog !

This is a portal exclusive for Nanostuffs Brightest Minds to share their technical, personal, and every kind of experience on web. We look forward to keeping you informed with timely articles on wide range of topics, such as:

  • iPhone/iPad Development
  • Android Development
  • Salesforce Customization/Apex Programming
  • PHP Insights
  • .NET Brainstorms
  • Unity 3D Challenges
  • HTML5 Examples
  • ….. and some general ramblings!

Hope you can subscribe to our blog feed, so that you’ll never miss an article. Please feel free to comment. We want to hear from you too.  Is there something specific you’d like for us to blog about?  If so, drop us an email (info@nanostuffs.com) and we’ll see what we can do.

Thank you for stopping by and we hope to see you soon.  Stay tuned.  Good things to come.

Cheers!
Nanostuffs Team

Nanostuffs

You pauperization to let at least 450 writers fix to construe ingress orders http://getresearchpaper.org/top-rated-writing-service-can-write-your-essay/ Near essays include points that can be supported by facts or by statements within the text that is existence analyzed When he came to see this look of himself, and lettered a figure for it, he did what was already typical of him at that maturity He went to the library

Using Schema.getGlobalDescribe() to get list of all fields in Salesforce Apex

I had one dropdown that had options – Lead, Account, Contact, Opportunities and some custom objects. Upon selection of any of this object, all the respective object’s standard and custom fields should be populated in another dropdown. This is how I achieved it:

Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(‘Account’).getDescribe().fields.getMap();

for(String s : objectFields.keySet())
{
      // process s
}

How to Create UILocalNotification, repeating every minute ?

There are two types of notifications in iOS, One is Local notification & other is PUsh notification. Added code to create Local notification.

// creating notification
NSDate *newDate = [NSDate dateWithTimeIntervalSinceNow:60];

// where 60 = seconds, so add your seconds here
Class cls = NSClassFromString(@”UILocalNotification”);
if (cls != nil) {
UILocalNotification *notification = [[cls alloc] init];
notification.fireDate = newDate;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.alertBody = @“My Notification”;
notification.alertAction = @”Show me”;
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
notification.repeatInterval = NSMinuteCalendarUnit;
NSString *str = @“String to pass”;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:str forKey:@“myNotification”];
notification.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release];
}

// receiving notification
– (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@”Notification: %@”, [notification.userInfo objectForKey:@“myNotification”]);
}

Nanostuffs Exhibits At GITEX Technology Week

Stand Location: Sheikh Saeed Hall 2, S1-MAC82GITEX is one of the largest and most important ICT events around the globe, GITEX delivers a leading platform for industry innovation and an impressive track record of attracting the biggest names in the IT sector, connecting over 3,500 domestic and international IT vendors with more than 136,000 ICT professionals. It had companies exhibiting from various sectors like Business Solutions, Cloud Computing, Consumer Technology, Government Systems, Mobile Apps & Content World, Digital Media and many other features and highlights.Nanostuffs hosted its presentation on a developer pod platform and had discussion with many industry professionals and enterpreneurs about our expertise in creating mobile applications and cloud computing skills. The quality of visitors was superb and direct interaction with decision makers was a plus. Nonetheless, it was a great learning experience to meet and understand requirements of people from several countries and backgrounds.More Details about the event can be found here

nanostuffs-at-gitex

Nanostuffs Celebrates its 1st Anniversary

Nanostuffs commenced with its office in Pune (India) and 2 employees on 1st October 2010. The journey was indeed a roller coaster ride. The company was founded by we two young enterprenuers – Nishant Bamb & Ankita Chordia. We both being just in our 20s of our age, starting a company was really a challenge and were skeptic about difficulties that will come ahead. But it’s true – hard work pays off. We worked diligently and arduously on many ventures and ideas to create a strong base for Nanostuffs and here we are after a year proud of ourselves that we did sustain all obstacles and brought Nanostuffs at a higher level.Starting with .NET and PHP services, we invested and researched into Mobile Apps since January 2011 and Cloud computing platforms and soon they came Nanostuffs major fortes. Until now we have worked on more than 70 apps for iPhone/iPad/Android/BB/Novia Ovi and several projects on Salesforce, AWS and GAE.

At present, we are working on 18 mobile apps development projects, 3 major PHP developments, 40+ sites content delivery services, on verge of becoming Salesforce ISV Partners and preparing to exhibit at GITEX Technology Week 2011, Dubai event which is middle east’s largest IT Sector Exhibition. Our vision for this year is to grow more in terms of resources, quality work, employee satisfaction and retention and getting into enterprise business.

We thank entire team of Nanostuffs for their hardwork and support to make this a successful year. Cheers to a new year and another chance for us to get it even more right & better !!! 🙂

Nanostuffs Exhibits At Mobile Apps Conclave Event, Bangalore (India)

Cellstrat hosted Mobile App Conclave 2011 at The Chancery Pavilion Hotel, Bangalore on 29th April 2011. The Conference saw tremendous interest with a large no of audience from all over India. The star-studded speaker lineup and intuitive content on Mobile Apps and Web fueled interest in this event. The theme for this event was : “The Mobile Web Disruption – Life, Media and Business get Appified”.This conference also saw an interesting exhibition on Mobile Solutions where some innovative app companies exhibited their apps and solutions. Nanostuffs was among one of such companies. We exhibited our range of services in developing Personal, Consumer, Business, Enterprise & Gaming Applications for Mobile platform.

More Details can be found here

Mobile-Apps-Conclave

Outset Course Impost Essays for UK Students! Our essays espouse all trouble levels pensacola christian college writing paper One Search the theme Comprehensive Run Ban Treaty has been employed to ban nuclear plosion for military and polite purposes.