LAZIOMATICA – Guida allo Sviluppo Software

La nuova forma del software su misura…

 

IOS iPhone/iPad – check call service capability of the device

sometimes you need to check the type of device that will use our application in order to identify whether the device is an iphone, ipod or iPad. To check this we can read the [UIDevice currentDevice].model such you are essentially comparing the device name with a hard-coded value. Example

if(![[UIDevice currentDevice].model isEqualToString:@"iPhone"])
{
UIAlertView *alertView = [UIAlertView alloc] initWithTitle:@"Error"
message:@"Call service not avalible on this device"
delegate:self
cancelButtonTitle:@"close"
otherButtonTitles: nil];
[alertView show];
[alertView release];
}

as alternative we can add a control if the device can openURL “tel:xxx-xxxx-xxxx” which is the protocol used to make a call on an iPhone device:

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:RISTOSTREGA_PHONE]]

more in deep we ca use to know exactly the generation of device the class UIDeviceHardware:

UIDeviceHardware *h=[[UIDeviceHardware alloc] init];
[self setDeviceModel:[h platformString]];
[h release];

the class UIDeviceHardware.h:

@interface UIDeviceHardware : NSObject
- (NSString *) platform;
- (NSString *) platformString;
@end

in the implementation file UIDeviceHardware.m:

#include
#include

@implementation UIDeviceHardware

- (NSString *) platform{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine];
free(machine);
return platform;
}

- (NSString *) platformString{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 4G";
if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator";
return platform;
}

@end

Filed under : Apple,Sviluppo iPad/iPhone,Xcode
By admin
On 18 febbraio 2011
At 07:49
Comments : 0
 
 

XCode Error launching remote program: failed to get the task for process xxx

Problem:
Hi i get this error when try to debug my app inside connected device. The app was launched regularly but i lost the connection to the debugger.
Solution:
There was an issue of certificates. In effetc i was using an adHoc Certificate that doesn’t support the debugger on device.

Filed under : Apple,MAC OSX,Sviluppo iPad/iPhone,Xcode
By admin
On 9 febbraio 2011
At 09:54
Comments : 0
 
 

How to build an Apple Push Notification provider server

here a good implementation of a fully work example of APN service integration inside your App.
http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial

Filed under : Apple,Sviluppo iPad/iPhone
By admin
On 7 febbraio 2011
At 12:19
Comments : 0
 
 

Introduction to use iPhone/iPad iOS MapKit Framework

Looking around internet i found this interesting article about mapkit http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/.

Filed under : Apple,Sviluppo iPad/iPhone
By admin
On
At 10:31
Comments : 0
 
 

Integrate the three20 library into your iOS project in 3 steps without error Can’t find #import “Three20/Three20.h”

Download three20 library with this command git clone git://github.com/facebook/three20.git

1) Copy the three20 folder into your iphone project: goto in [YourProjectsFolders]/[iOSProjectName] and copy three20 folder here
2) from console locate the three20 folder and run this python command
python src/scripts/ttmodule.py -p ../[iOSProjectName].xcodeproj Three20 -c Debug -c Release
3) now go to XCode and build. If yet opened reload project.

Filed under : Apple,scripts,Sviluppo iPad/iPhone
By admin
On 3 febbraio 2011
At 08:38
Comments : 0
 
 

XCode iPad Development – Debug Error launching remote program: failed to get the task for process 207

If you are having this error

Error launching remote program: failed to get the task for process 207

Take care to have a debug profile and if have the file Entitlements.plist, open it and set the boolean value get-task-allow to YES.

I solved in this way.

Filed under : Apple,MAC OSX,Sviluppo iPad/iPhone
By admin
On 29 novembre 2010
At 15:47
Comments : 0
 
 

iPad / Iphone – Hide Statusbar

To hide the application statusbar we can choose 2 way:

add this key  and set it boolean value to “true” inside the application info.plist

<key>UIStatusBarHidden</key>

<true />


or using the application singletone class programmatically,
in this way:


[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

this is all

Filed under : Apple,MAC OSX,Sviluppo iPad/iPhone
By admin
On
At 09:29
Comments : 0
 
 

Ad Hoc iPhone Apps Distribution Guide Published

Here a link to a useful guide for install iPad/iPhone app without using Applestore

Filed under : Apple,Sviluppo iPad/iPhone
By admin
On 9 ottobre 2010
At 16:06
Comments :Commenti disabilitati
 
 

Developing for iPad/iPhone – Add iTunes artwork for ad hoc distribution

When deploying an application using the ad hoc distribution “style”, the developer has to supply the image shown in the installed applications tab of iTunes. This file has to be a 512 by 512 PNG or JPEG image called iTunesArtwork that has to be extension-less. You have to manually delete the extension and check that the file type is no set to jpg or png for it to work and show up in iTunes, this step is vital and isn’t documented. Without the iTunesArtwork, iTunes will show a generic image for your application.
To check and change file type i used “FileType” freeware software

Filed under : Apple,MAC OSX,Sviluppo iPad/iPhone
By admin
On 11 settembre 2010
At 13:50
Comments :Commenti disabilitati
 
 

Programmazione iPad/iPhone – UI dinamica: come accedere alle view create dinamicamente attraverso il “tag”

Partendo dall’esempio precedente, se volessimo accedere ad una view creata in modo dinamico a cui abbiamo assegnato la proprietà “tag”, possiamo recuperarla dalla view della classe con riferimento al tag, effettuandone però un cast al tipo di View che rappresenta. Nel esempio concreto se vogliamo alterare la proprietà “text” della UILabel, possiamo farlo in questo modo, magari al click del bottone:

-(IBAction) buttonClicked: (id) sender{

//Effettuo il cast a UILABEL recuperandola dalla view principale attraverso il suo tag

UILabel *myLabel = (UILabel *)[self.view viewWithTag:1000];

myLabel.text=@”Questa è la mia etichetta”;

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@”Pulsante click!”

message:@”Ciao, ti piace questo esempio?!”

delegate:self

cancelButtonTitle:@”Chiudi”

otherButtonTitles:nil];

[alert show];

[alert release];

}

Questo è valido per qualsiasi altro tipo di view.

Filed under : Apple,Sviluppo iPad/iPhone
By admin
On 29 agosto 2010
At 17:49
Comments :Commenti disabilitati