Articles Tagged 'Google Code'


Coding Guidelines

When you are not working alone for most all developers comes time to find guidance in the writing of the code. Protocols and standards to allow "read" easily and intervene (more easily) in the code of others.
When we work on a project more programmers, often of different languages, you must find a common form of writing, in the standard internal and external documentation to the code. In my work I am normally interact with:

  • Objetive-C, C / C + +
  • PHP
  • HTML
  • Javascript
  • Actionscript
  • CSS

Continued ...

iPhone SecondApp: guess the number - part 2

As mentioned in the iPhone FirstApp: guess the number - Part 1 we see how to make an application for the Apple iPhone without using Interface Builder! Indeed, we will eliminate physically the files created by the wizard Interface Builder of Xcode. At the end of this post, then, we will have an application identical in all respects, to that achieved in the first part, with the difference that we will achieve all our visual components, including the main Window, completely to code.

The application already made, if you just want to download it, it is available on my Google Code repository:

I would like to point out immediately as the ZIP of this example weighs less than the last time! :)

We create the project

Let's start creating our project SecondApp (to distinguish it from FirstApp), although this time we will choose Window-based Application:

newproject

Now let's remove everything related to Interface Builder. : eliminatelo anche dal file system, quindi selezionate Also Move to Trash . Eliminate the file MainWindow.xib , located in your Resources : also delete it from the file system, then choose Also Move to Trash. nella casella Main nib file base name : Selected, then the file SecondoApp-info.plist and delete the reference to the MainWindow in the box Main TR base file name:

deleteib

At this point we no longer have any Window, at least through Interface Builder. , e modifichiamo la funzione main() in questo modo: Then open the file main.m , located in Other Sources , and modify the function main() in this way:

1
2
3
4
5
6
7
8
9
10
11
int argc, char * argv [ ] ) { int main (int argc, char * argv []) {

pool = [ [ NSAutoreleasePool alloc ] init ] ; NSAutoreleasePool * pool = [[ NSAutoreleasePool alloc] init];

/ / Having deleted the file. Xib we lost pointing
/ / The app delegate, then pass it to "hand"
UIApplicationMain ( argc, argv, nil , @ "SecondAppAppDelegate" ) ; int retVal = UIApplicationMain (argc, argv, nil, @ "SecondAppAppDelegate");

; [Pool release];
return retVal;
}

Let's open SecondAppAppDelegate.me create the main Window in code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void ) applicationDidFinishLaunching : ( UIApplication * ) application { - (Void) applicationDidFinishLaunching: (UIApplication *) application {

/ / Get the size of the screen (320, 480)
UIScreen mainScreen ] applicationFrame ] ; CGRect windowRect = [[UIScreen mainScreen] applicationFrame];
/ / Create a window - as we have done bye bye to Interface Builder
[ [ UIWindow alloc ] initWithFrame : windowRect ] ; UIWindow * mainWindow = [[UIWindow alloc] initWithFrame: windowRect];
/ / Set the background of the Window to yellow, to differentiate
/ / From the previous application FirstApp
[ UIColor yellowColor ] ] ; [MainWindow setBackgroundColor: [UIColor Yellow Color]];

mainWindow ] ; [Self SetWindow: mainWindow];
; [Window makeKeyAndVisible];

; [MainWindow release];
}

You can already test the application, if you get a yellow window you did everything right!

, necessario solo se si usa Interface Builder. In the file SecondAppAppDelegate.h we can eliminate IBOutlet , only needed if you use Interface Builder. We also add here that our global variables, in the last time, we had entered into the controller. Then modify the file SecondAppAppDelegate.h :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Import <UIKit/UIKit.h>

NSObject <UIApplicationDelegate> { @ Interface SecondAppAppDelegate: NSObject {<UIApplicationDelegate>
UIWindow * window;

UITextField * number;
UIButton * button;
int numeroACaso;
}

nonatomic, retain ) UIWindow * window; @ Property (nonatomic, retain) UIWindow * window;

void ) controllaNumero; - (Void) getNumber;

@ End

, in quanto non stiamo usando Interface Builder. Also in this case we have prepared the method definition controllaNumero , as last time, but we have eliminated the indication IBAction , since we are not using Interface Builder.

We build the interface code

It 'time to create code using all the components of our interface. ed inseriamo il seguente codice: Let's go back to the file SecondAppAppDelegate.m , posizioniamoci before the [mainWindow release] and insert the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/ / Create the title bar
[ [ UINavigationBar alloc ] initWithFrame : CGRectMake ( 0.0 , 0.0 , 320.0 , 44.0 ) ] ; UINavigationBar * myNavigationBar = [[UINavigationBar alloc] initWithFrame: CGRectMake (0.0, 0.0, 320.0, 44.0)];
myNavigationBar.barStyle = UIBarStyleDefault;
[ [ UINavigationItem alloc ] initWithTitle : @ "Indovina un numero" ] ; UINavigationItem navigationItem * = [[UINavigationItem alloc] initWithTitle: @ "Guess a number"];
navigationItem animated : NO ] ; [MyNavigationBar pushNavigationItem: navigationItem animated: NO];
myNavigationBar ] ; [Window addSubview: myNavigationBar];

/ / Create the label
[ [ UILabel alloc ] initWithFrame : CGRectMake ( 10 , 50 , 300 , 80 ) ] ; UILabel * myLabel = [[UILabel alloc] initWithFrame: CGRectMake (10, 50, 300, 80)];
UIColor clearColor ] ; myLabel.backgroundColor = [UIColor clearColor];
; myLabel.numberOfLines = 2;
"iPhone ha pensato un numero da 1 a 10, prova ad indovinarlo?" ; myLabel.text = @ "iPhone has seen a number from 1 to 10, try to guess?"
myLabel ] ; [Window addSubview: myLabel];

/ / Create text input
UITextField alloc ] initWithFrame : CGRectMake ( 10 , 120 , 300 , 30 ) ] ; number = [[UITextField alloc] initWithFrame: CGRectMake (10, 120, 300, 30)];
numero.borderStyle = UITextBorderStyleRoundedRect;
numero.textAlignment = UITextAlignmentCenter;
numero.keyboardType = UIKeyboardTypeNumberPad;
"Inserisci il numero" ; numero.placeholder = @ "Enter the number";
numero ] ; [Window addSubview: number];

/ / Create the button
UIButton buttonWithType : UIButtonTypeRoundedRect ] ; button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
10 , 180 , 300 , 30 ) ; bottone.frame = CGRectMake (10, 180, 300, 30);
@ "Premi qui" forState : UIControlStateNormal ] ; [Button setTitle: @ "Click here" forState: UIControlStateNormal];
self action : @selector ( controllaNumero ) forControlEvents : UIControlEventTouchUpInside ] ; [AddTarget button: self action: @ selector (getNumber) forControlEvents: UIControlEventTouchUpInside];
bottone ] ; [Window addSubview: button];

; [MyLabel release];
; [NavigationItem release];
; [MyNavigationBar release];

della scorsa volta, subito dopo il [mainWindow release]; inseriamo: Since l ' applicationDidFinishLaunching corresponds to viewDidLoad of last time, immediately after the [mainWindow release]; insert:

1
+ arc4random ( ) % 10 ; numeroACaso arc4random = 1 + () 10%;

Now we just have to implement the method controllaNumero , which will be identical (apart from the prototype) to the one used last time:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void ) controllaNumero { - (Void) {getNumber
"Premuto bottone di controlla numero" ) ; NSLog (@ "pressed button control number");
[ numero.text integerValue ] ; numeroInserito int = [numero.text integerValue];
message; NSString * message;
"Il numero inserito è %d" , numeroInserito ) ; NSLog (@ "The number entered is% d", numeroInserito);
numeroInserito <numeroACaso ) { if (numeroInserito <numeroACaso) {
"Troppo basso..." ; message = @ "Too low ...";
( numeroInserito> numeroACaso ) { } Else if (numeroInserito> numeroACaso) {
"Troppo alto..." ; message = @ "Too high ...";
( numeroInserito == numeroACaso ) { } Else if (numeroInserito numeroACaso ==) {
"Bravo hai indovinato" ; message = @ "Bravo you guessed";
+ arc4random ( ) % 10 ; numeroACaso arc4random = 1 + () 10%;
"Numero pensato %d" , numeroACaso ) ; NSLog (@ "% d Number thought," numeroACaso);
}
[ [ UIAlertView alloc ] UIAlertView * alertMessaggio = [[UIAlertView alloc]
"Responso" initWithTitle: @ "Response"
message: message
delegate: nil
"OK" cancelButtonTitle: @ "OK"
] ; otherButtonTitles: nil];
; [AlertMessaggio show];
; [AlertMessaggio release];
"" ; numero.text = @ "";
}

We are done!

Conclusions and considerations

, proprio perchè volevo lasciarlo il più semplice e snello possibile e, anche, per dimostrare che non sono elementi sempre necessari. This example does not make direct use of a UIView or a UIViewController , because I wanted to leave it as simple and streamlined as possible and, also, to show that items are not always necessary. However insert objects directly into the window can have some sense in this example and in other contexts sporadic. portano comunque benefici in tantissimi altri casi, ein alcuni sono praticamente indispensabili; come avremo modo di vedere in futuro. The use of UIView and UIViewController still bring benefits in many other cases, andin some are practically indispensable, as we will see in the future.

Continued ...

iPhone FirstApp: guess the number - part 1

The first source that I spent in my hands was written in Basic and consisted of a few lines of code, for enlightening me. It was a simple game that generated a random number from 1 to 10 and, through keyboard input, checked that the number entered was Maggione, less than or equal to the random number. Despite its rough simplicity remains, for me, one of the best examples - simple, fun and practical - to explain to those who do not know anything about programming actually what is meant by "computer program". So I thought to propose it for Apple iPhone, maybe someone will help ...

Continued ...

Simple Slider jQuery 1.1.0

l'attributo rel in questo modo: Taking a cue from the suggestion of Santino Bivacqua I added Simple jQuery Slider can be set for each slide a timeOut different, inserting tags in li the attribute rel in this way:

Continued ...

Simple jQuery Slider

Simple jQuery Slider allows you to quickly create a slide show feature from a simple list UL/LI :

Continued ...

footer caption jQuery Plugin: add captions to images

jquery.footercaption.js is a plugin for jQuery able to dynamically add captions to images and other elements on the page ( click here for a demo).

Continued ...

Skypemote Adobe AIR version: 1000 download

Skypemote version of Adobe AIR

Continued ...

Adobe AIR APIs and Feedburner: reloaded

I take inspiration by the excellent tutorial Napolux , Flex 3 and Adobe AIR APIs Feedburner , which shows how to write a simple application (or widget) Adobe AIR using Flex 3, to show how to accomplish the same thing using Adobe Flash CS3. If you wish, also, you can take advantage of the extension for creating Adobe AIR applications. It is not necessary for the purposes of this tutorial, compile your AIR application as an executable, you can use the code proposed as a simple Flash movie "affix" to your Web pages

Continued ...

Skypemote version of Adobe AIR

Download Skypemote Install Adobe AIR Version

This is the first release, 0.8 (aligned with version online ), Skype Emotions Editor - Skypemote - version of Adobe AIR . For now, the features are the medisime version online , with the advantage of being a desktop application, then be installed on Windows, Mac and Linux.
Before installation, remember to update and / or install for the first time the runtime Adobe AIR , if you have not already done so.

Download

You can download Air Skypemote from Google Code .

Continued ...

Undolibrary MatrixArray: an extension of the Array class

di Actionscript 3.0, con lo scopo di semplificare la manipolazione di Array lineari usati come matrice n x m . MatrixArray is an extension of the class Array of Actionscript 3.0, with the purpose to simplify the manipulation of Array linear used as a matrix n x m. This class is part of the library Undolibrary (in the package undolibrary.utils.MatrixArray ) that you can freely download function from any client through a Google code SVN (Subversion) to:
svn checkout http://undolibrary.googlecode.com/svn/trunk/
Alternatively, you can download only one file MatrixArray.as . An example of the use of linear arrays has been given in Actionscript 3.0 for beginners: lesson # 2 where we saw one of its mere use in the production of the classic Tic Tac Toe game. ), proprio come una scacchiera. A matrix of this type is comparable to a rectangular area ( w x h ), just like a chessboard. With this class, it is possible to treat an array of this type just like a lattice with its x and y coordinates. The MatrixArray I used, for example, in the development of all the logic editor of Emotions Icons for Skype: Skypemote .

Continued ...