Archive June, 2009


Best Technical Blog Italian 2008-2009: the winner declared

They closed the vote for the Best Technical Blog Italian 2008-2009 , an initiative conceived by Christian until , at the time the project is unique in the Italian blogosphere.

More ...

Apple iPhone 3.0 SDK: Fixed bug on UIButton buttonWithType

As indicated in the post Apple iPhone SDK 3.0: first incompatibility of the Apple SDK 3.0 show different behaviors with respect to release 2.2.1. Support service for developers gave me the answer, and then the solution to the problem. . The answer was that the technical support [UIButton buttonWithType:] already called - inside - the initWithFrame . It follows that, according to tech support, writing:

More ...

From Actionscript to Objective-C

I thought it might be useful to those who have recently approached the development of applications for Apple iPhone, compare Adobe ActionScript - the language used in Adobe Flash and Adobe Flex, more common among the neo-programmers - and Objective-C language used by Apple to develop its applications. Objective-C is in effect an object-oriented language in the pure sense, not that Actionscript is not, but Objective-C is definitely a plus because it is an extension of ANSI C and its syntax is a mix between C / C + + and Smalltalk, is a true OO (Object-oriented language).

More ...

Apple iPhone SDK 3.0: first incompatibility

After you install the SDK 3.0 for Apple iPhone, evidently still not perfectly stable, I immediately noticed some problems, both in the compilation of the code is in the general XCode. The most important - which I promptly reported with a "home" to Apple, developers at the center - the creation of buttons through code. Here's an excerpt of the code is not compatible with SDK 3.0:

1
2
3
4
[ [ UIButton buttonWithType : UIButtonTypeRoundedRect ] initWithFrame : CGRectMake ( 0 , 0 , 100 , 40 ) ] ; UIButton * myButton = [[UIButton buttonWithType: UIButtonTypeRoundedRect] initWithFrame: CGRectMake (0, 0, 100, 40)];
@ "Bottone" forState : UIControlStateNormal ] ; [MyButton setTitle: @ "Button" forState: UIControlStateNormal];
/ / Other settings
myButton ] ; [Self.view addSubview: myButton];

By filling out this code with the SDK 2.2.1 you get a classic button with the label "Button". With the SDK 3.0, the button is created, but the label disappears. la situazione sembra migliorare, nel senso che la label viene resa apparentemente in modo corretto. Using as buttonWithType the type UIButtonTypeCustom the situation seems to improve, in the sense that the label is apparently made ​​correctly. It is still strange to the sudden failure of the type UIButtonTypeRoundedRect . I am still awaiting a response from Apple ... I just novelties; place!

More ...

The First: Available on iTunes

Six days and AppStore has approved the (my) first application for Apple iPhone!

More ...

iPhone: the very useful property tag

All objects that derive from <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/cl/UIView">UIView</a> inherit the useful properties <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW25">tag</a> This property is a real user-data (a "place" that the developer used for general purposes) of type <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSInteger">NSInteger</a> so where we can store only numbers.

The uses to which they can do of course depend on the circumstances, however, it is useful to identify a particular object to taking a common occurrence. For example imagine you have two <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIAlertView_Class/UIAlertView/UIAlertView.html">UIAlertView</a> respond to the same event:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/ / First alert
[ [ UIAlertView alloc ] initWithTitle : @ "Primo" message : @ "Primo Alert" delegate : self cancelButtonTitle : @ "OK" otherButtonTitles : nil , nil ] ; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "First" message: @ "First Alert" delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];
; [Alert show];
; [Alert release];

/ / ...

/ / Second alert
[ [ UIAlertView alloc ] initWithTitle : @ "Secondo" message : @ "Secondo Alert" delegate : self cancelButtonTitle : @ "OK" otherButtonTitles : nil , nil ] ; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "second" message: @ "Second Alert" delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];
; [Alert show];
; [Alert release];

/ / Event
/ / Alter the OK button Cliccandi will call this function
void ) alertView : ( UIAlertView * ) alertView clickedButtonAtIndex : ( NSInteger ) buttonIndex { - (Void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) {buttonIndex
/ / Todo
}

Note: The examples of code will display the C + +. This is not entirely correct because, as you know, the language is Objective-C. This is due to the fact that the plugins I use to view the source code does not support Objective-C and C + + is the one that best approaches him.

How to differentiate between the two alert? Precisely using the property tag. After creating the alert just enter:

1
2
3
4
5
6
7
8
9
10
11
12
13
/ / First alert
[ [ UIAlertView alloc ] initWithTitle : @ "Primo" message : @ "Primo Alert" delegate : self cancelButtonTitle : @ "OK" otherButtonTitles : nil , nil ] ; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "First" message: @ "First Alert" delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];
1 ] ; // imposto il tag di questo Alert ad 1 [Alert SETTING: 1]; / / set the tag of this Alert to 1
; [Alert show];
; [Alert release];

/ / ...

/ / Second alert
[ [ UIAlertView alloc ] initWithTitle : @ "Secondo" message : @ "Secondo Alert" delegate : self cancelButtonTitle : @ "OK" otherButtonTitles : nil , nil ] ; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "second" message: @ "Second Alert" delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil, nil];
2 ] ; // imposto il tag di questo Alert ad 2 [Alert SETTING: 2] / / set the tag of this Alert to 2
; [Alert show];
; [Alert release];

Now modify the event in order to understand which Alert has been closed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/ / Event
/ / Alter the OK button Cliccandi will call this function
void ) alertView : ( UIAlertView * ) alertView clickedButtonAtIndex : ( NSInteger ) buttonIndex { - (Void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) {buttonIndex
alertView.tag ) { switches (alertView.tag) {
: case 1:
/ / First Alert
break;
: case 2:
/ / According Alert
break;
default:
break;
}
}

Exact same technique can be used if we have a series of <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIButton_Class/UIButton/UIButton.html">UIButton</a> runtime. For example:

1
2
3
4
5
6
7
8
9
10
unsigned int i = 0 ; i < 10 ; i ++ ) { for (unsigned int i = 0; i <10; i + +) {
[ [ UIButton buttonWithType : UIButtonTypeCustom ] initWithFrame : CGRectMake ( i * 20 , i * 20 , 20 , 20 ) ] ; UIButton * myButton = [[UIButton buttonWithType: UIButtonTypeCustom] initWithFrame: CGRectMake (i * 20, * 20, 20, 20)];
@ "But" forState : UIControlStateNormal ] ; [MyButton setTitle: @ "But" forState: UIControlStateNormal];
i ] ; // imposto il tag [MyButton SETTING: i]; / / set the tag

/ / The same event for all
self action : @selector ( onTouchUpInside : ) forControlEvents : UIControlEventTouchUpInside ] ; [MyButton AddTarget: self action: @ selector (onTouchUpInside:) forControlEvents: UIControlEventTouchUpInside];

mybutton ] ; [Self.view addSubview: myButton];
}

(dove eseguiamo un casting <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/cl/UIView">UIView</a> In the event onTouchUpInside recover from the sender (where we perform a casting <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/cl/UIView">UIView</a> property <a target="_blank" href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW25">tag</a>

1
2
3
4
void ) onTouchUpInside : ( id ) sender { - (Void) onTouchUpInside: (id) sender {
( ( UIView * ) sender ) .tag; unsigned int button_tag = ((UIView *) sender). tag;
/ / Todo
}

More ...

Very short snippet: Display a list of posts by category or tags

Two useful features, customizable at will, to use to display the last n posts in a category or one or more tags. Functions, as you will see, are very similar and are both based on a loop generated by query_post() . The first, show_title_cat() , shows the last post (in this version only the title) of a specific category:

More ...

A WordPress theme for all

Under the title of the blog, on the left, just above the navigation bar, there is a "switch" that allows you to switch to an alternative graphical theme, namely "clear".

The graphic theme of a blog is chosen by the blog owner himself, whether it is created by hand, whether it was downloaded from the network. The end result, however, in addition to "us" owners should be pleased by our visitors who do not always appreciate certain layout choices. For some it will be trivial for other wonderful, for others still terribly annoying! Why, then, do not choose the "visitor" the layout with which to view our blog?

More ...

Hi phone

iphone From today inaugurated a new section (category to be corrected) dedicated to developing applications on Apple iPhone! I state now that many of the items that will be publishing a "cut" in line with the spirit of this blog, that will be mostly for advanced users. However, as I have done this in other topics, try to be as clear as possible and, where necessary, put some "basic concept" useful to a wider audience.

More ...



Stop SOPA