RSS

Archivi autore: theolternative

About theolternative

Mac, Music & Mountaineering

iPhone dev memoramda #2

View controllers can load a view from a nib with

-(id) initWithNibName:bundle:

OR

-(void) loadView

. They CAN’T be used at the same time. Setup happening just once should occur in

-(void) loadDidLoad

but beware: bounds data are not yet set. Otherwise

-(void) viewWillAppear

should be’ used.

 
Leave a comment

Pubblicato da su gennaio 4, 2011 in Uncategorized

 

iPhone dev memoranda #1

IBOutlet views should be declared as retained properties, stnthesized and released in viewDidUnload and dealloc methods of their controllers by setting their values to nil.

@interface MyController : NSObject
{
   MyView *myView;
}
@property (retain) IBOutlet MyView *myView;
@end

@implementation MyController
@synthesize myView;
-(void) releaseViews
{
   self.myView=nil;
}
-(void) viewDidUnload
{
   [self releaseViews];
}
-(void) dealloc
{
   [self releaseViews];
....
}

 
Leave a comment

Pubblicato da su gennaio 3, 2011 in Uncategorized

 

Cocoa Dev Quick NotesNSTableView: Drag & Drop and Edit Menu Validation

All methods are updated to Mac OS 10.6.

Drag & Drop

Follow this steps to use drag & drop in NSTableView:

  • Create a custom view controller class MyTableViewController based on NSViewController
  • Add a new XIB based on an empty view and assign the newly added class to its File’s Owner
  • Drop in a NSTableView and assign its dataSource outlet to File’s Owner
  • Use Core Data for populating the table
  • Define a custom pasteboard type (only if you aren’t using standard types):
    NSString *MyCustomPBoardType = @"MyCustomBoardType";
    
  • In your view controller’s awakeFromNib method add the following lines:
    NSArray *dragTypes = [NSArray arrayWithObjects: MyCustomPBoardType,nil];
    [myTableView registerForDraggedTypes:dragTypes];
    [myTableView  setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
    
  • Implement the tableView:writeRowsWithIndexes:toPasteboard: method to handle dragging and tableView:validateDrop:proposedRow:proposedDropOperation: and tableView:acceptDrop:row:dropOperation: to handle dropping:
    - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard
    {
    	NSArray	*selectedObjects = [myArrayController selectedObjects];
    	[pboard declareTypes:[NSArray arrayWithObjects:MyCustomPBoardType,nil] owner:self];
    	for( NSManagedObject *object in selectedObjects )
    		[pboard writeObjects:[NSArray arrayWithObject:[[object objectID] URIRepresentation]]];
    
        return YES;
    }
    
    - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id )info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op
    
    {
    	if ([info draggingSource] == tv)
    	{
    		[tv setDropRow:row dropOperation:NSTableViewDropAbove];
    		return NSDragOperationNone;
    	}
    	else {
    		return NSDragOperationCopy;
    	}
    
        return NSDragOperationNone;
    }
    
    - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info row:(int)row dropOperation:(NSTableViewDropOperation)operation
    {
    	BOOL	acceptDrop = NO;
    
    	if( [info draggingSource] == aTableView )
    		return acceptDrop;   // it allows only drops from external sources
    
    	NSArray			*classes = [[NSArray alloc] initWithObjects:[NSURL class], nil];
    	NSDictionary	*options = [NSDictionary dictionary];
    	NSArray			*copiedItems = [[info draggingPasteboard] readObjectsForClasses:classes options:options];
    	if( !copiedItems )
    		return acceptDrop;
    
    	// do whatever you like with copied items
    	NSArray	*currentEvents = [objectsArrayController selectedObjects];
    	for( NSManagedObject *event in currentEvents )
    	{
    		NSSet	*attendants = [event valueForKey:@"attendants"];
    		NSMutableSet	*newAttendants = [[[NSMutableSet alloc] initWithCapacity:0] autorelease];
    		[newAttendants setSet:attendants];
    		for( NSURL *copiedObject in copiedItems )
    			[newAttendants addObject:[self.managedObjectContext objectWithID:[[self.managedObjectContext persistentStoreCoordinator] managedObjectIDForURIRepresentation:copiedObject]]];
    		[event setValue:newAttendants forKey:@"attendants"];
    		acceptDrop = YES;
    	}
    	return acceptDrop;
    }
    

Edit Menu Validation

The simplest way to validate cut:, copy: and paste: actions for rows in a table without subclassing NSTableView is to delegate the view controller.

  • The responder chain will ask first the NSTableView object and then will look for the next responder. So it’s simple to set the view controller as the next responder in your awakeFromNib method:
    [myTableView setNextResponder:self];
  • Now implement the request actions in your view controller:
    - (IBAction)copy:(id)sender
    {
    ...
    }
    
    - (IBAction)cut:(id)sender
    {
    ...
    }
    
    - (IBAction)paste:(id)sender
    {
    ...
    }
    // and whatever you like
    
  • Validate the interface:
    - (BOOL)validateUserInterfaceItem:(id )anItem
    {
        if ([anItem action] == @selector(copy:)) {
    		return [self canCutCopyDeleteOrDuplicate];
    	}
        return YES;
    }
    
  • Useful links

    NSTableView
    Drag And Drop

     
Leave a comment

Pubblicato da su marzo 14, 2010 in Uncategorized

 

40 giorni di WiFiPhoto|40 days on sale

US-AppStore-Staff-PicksWiFiPhoto has been on sale for 40 days now. Some frustrations, many satisfactions. In the beginning I didn’t know what to expect. Just after its release I discovered I had made a terrible mistake. When you submit an application to Apple you decide the release date. I chose to leave the submission date, 22nd August. WiFiPhoto went on sale on 4th September. I didn’t know I could change my release date: my app was buried amidst tons of other apps and it didn’t get any benefit from being just released. A hard lesson that I’ve definitely learned. I sent a quick press release to Macity one of the most popular Mac and iPhone related websites in Italy (perhaps the MOST popular. take a look at Alexa). My sales readily took off. In a week I had sold over 2,000 apps only in Italy. Japanese friends also gave me satisfaction: some bloggers made a good review and it helped a lot. Indeed I was primarily interested in USA but at first things were very difficult (even because of a misleading customer’s review).WiFiPhoto è ormai in vendita da 40 giorni. Qualche frustrazione, molte soddisfazioni. All’inizio non sapevo che aspettarmi. Appena dopo il rilascio ho scoperto di aver fatto un terrible errore. Quando si invia un’applicazione ad Apple, si può indicare la data di rilascio. Io avevo scelto di lasciare la data di invio, 22 agosto. WiFiPhoto è andato online il 4 settembre. Non sapevo che avrei potuto cambiare la data di rilascio: la mia applicazione era sepolta tra tonnellate di altre applicazioni e non aveva ricevuto nessuna visibilità dal fatto di essere stata appena pubblicata. Una dura lezione che ho imparato a mie spese. Ho subito inviato una nota informativa a Macity uno dei siti per Mac e iPhone più popolari qui in Italia (forse il più popolare guardando le statistiche di Alexa). Le mie vendite sono decollate subito. In una settimana avevo venduto 2000 applicazioni solo in Italia. Anche gli amici giapponesi mi hanno dato soddisfazione: alcuni blogger mi hanno fatto una buona recensione ed è servita un sacco. In verità ero in primo luogo interessato agli Stati Uniti ma all’inizio le cose erano molto difficili (anche a causa di una recensione fuorviante).
I decided to release a new update implementing various features I was requested. This time I chose to promote my app via a PR on prMac. And I didn’t forget to change my release date as soon as it became available on the AppStore. Eventually I got some attention from american users. I reached #26 in US AppStore in Photography category. In the meantime I had conquered some visibility even on other foreign AppStores. By now I’ve sold more than 5,000 apps all around the world. That’s not my first job (luckily) and I’m quite happy.Ho deciso di rilasciare un nuovo aggiornamento implementando le varie richieste degli utenti. Questa volta ho scelto di promuovere l’applicazione con comunicati stampa su prMac. E non mi sono dimenticato di cambiare la data di rilascio non appena è stata disponibile l’applicazione. Alla fine ho ricevuto un po’ di attenzione dagli utenti americani. Ho raggiunto la posizione 26 sull’AppStore USA nella categoria Fotografia. Intanto avevo conquistato visibilità anche su altri AppStore stranieri. Finora ho venduto 5000 applicazioni in tutto il mondo. Non è il mio primo lavoro (fortunatamente) e sono abbastanza contento.
Anyway I received my greatest satisfactions from customers and they’re by far more pleasant than any financial result. Now I’m ready for version 1.2 but in the meantime I’m enjoying WiFiPhoto among “Staff Picks” on US AppStore ! Apple always rewards you.Ad ogni modo ho ricevuto le mie più grandi soddisfazioni dagli utenti e sono molto più piacevoli dei risultati finanziari. Adesso sono pronto per la versione 1.2 ma nel frattempo mi sto godendo WiFiPhoto tra gli “Staff Picks” sull’AppStore americano ! Apple ti ripaga sempre.

 
4 Comments

Pubblicato da su ottobre 13, 2009 in Uncategorized

 

Una veloce introduzione a WiFiPhoto|A quick introduction to WiFiPhoto

 
4 Comments

Pubblicato da su settembre 25, 2009 in Uncategorized

 

Recensioni fuorvianti|Misleading customer reviews

As a developer I think it’s really weird the fact that I can’t answer to customers’ reviews. Especially if they claim something totally wrong. Two users from USA wrote in their reviews that WiFiPhoto scales down images before download. But it’s simply false. WiFiPhoto keeps photos at their original dimensions. So if you’re downloading a 1200×1600 pixel picture taken by your iPhone 3G’s camera, you’ll end up finding a 1200×1600 pixel picture on your computer. So, what’s happening ?Come sviluppatore penso che sia veramente strano il fatto che non possa rispondere alle recensioni dei miei clienti. Soprattutto se asseriscono qualcosa di totalmente sbagliato. Due utenti americani hanno scritto nelle loro recensioni che WiFiPhoto rimpicciolisce le immagini prima del download. Ma è semplicemente falso. WiFiPhoto conserva le dimensioni originali. Quindi se scaricate un’immagine da 1200×1600 pixel con la fotocamera del vostro iPhone 3G, finirete con il trovarvi un’immagine da 1200×1600 pixel sul vostro computer. E allora che succede ?
They simply ignore the fact that even the original photo they chose to download was not full resolution. There are different reasons. Perhaps they used some third-party camera app to take pictures with a zoom. Or perhaps, more probably, they transferred photo albums from iPhoto to their iPhones ignoring the fact the iPhoto shrinks and compresses images. So if you think to recover images from your iPhone after a crash of your hard drive, I have some bad news for you: you can’t. Or at least you won’t be able to recover your full resolution original pictures, simply because they’re NOT on your iPhone.Semplicemente ignorano il fatto che anche l’immagine originale che hanno scelto di scaricare non era a piena risoluzione. Ci sono vari motivi. Forse hanno usato un’applicazione per scattare foto con lo zoom. O forse, più probabilmente, hanno trasferito album fotografici da iPhoto ai loro iPhone ignorando il fatto che iPhoto riduce e comprime le immagini. Quindi se pensi di poter recuperare le immagini dal tuo iPhone dopo un crash del tuo hard-disk, ho una brutta notizia da darti: non puoi!. O almeno non potrai recuperare le tue immagini a piena risoluzione semplicemente perchè NON SONO sul tuo iPhone.
I’m sorry for this, but being unable to answer wrong customers’ complaints is frustrating.Mi dispiace ma non potere rispondere a critiche sbagliate è frustrante.

 
2 Comments

Pubblicato da su settembre 20, 2009 in Uncategorized

 

WiFiPhoto

ArtworkE’ finalmente disponibile sull’AppStore la mia prima applicazione per iPhone. Nasce da un problema reale con cui mi sono scontrato più volte: il download delle foto su computer che non fossero i miei. A casa uso iPhoto con il mio Mac ma molto spesso mi capita di scattare foto sul lavoro e non ho la possibilità di inviarle sui computer in ufficio. Spedirle via mail è lento e macchinoso. La soluzione ? WiFiPhoto. L’applicazione consente di scegliere più immagini o dal rullino fotografico o dalla libreria e di scaricarle da un qualsiasi computer collegato in rete locale (ovviamente dev’essere un punto di accesso WiFi per iPhone) singolarmente o compresse in un unico file zip. Il tutto è tanto semplice quanto aprire un browser ed impostare l’indirizzo indicato da WiFiPhoto. Niente di più. Maggiori informazioni nella pagina specifica.At last my first iPhone application is available on the AppStore. It was thought as a solution to my worst problem with iPhone: how to download photos to computers without a usb cable. iPhoto is my first choice when I’m home on my Mac but I very often take shots for work and I can’t download them at the office. Sending in emails is complicated and sluggish. My solution ? WiFiPhoto. This app lets you pick multiple photos from the Camera Roll or from the Photo Library and lets you download them to any computer over a local network (there must be a WiFi connection for the iPhone anyway) one at a time or altogether compressed in a zipped file. It’s as easy as opening on your favourite browser the web address displayed by WiFiPhoto. Nothing more. More info at the product page.

 
9 Comments

Pubblicato da su settembre 5, 2009 in Uncategorized

 

WordPress e Thesis: coppia perfetta|WordPress and Thesis: perfect match

Alla fine sono riuscito a sostituire Joomla con WordPress. A non tornerò indietro. WordPress è semplicemente più facile, più bello e più veloce. Qualunque cosa tu faccia o qualunque sia il tuo obiettivo, è assolutamente La Scelta. Ogni nuova versione porta nuove opzioni, nuovi elementi d’interfaccia che fanno la gioia degli occhi e caratteristiche che consentono di risparmiare tempo. Il passaggio da Joomla 1.0 alla 1.5 non ha portato nulla di realmente soddisfacente ai semplici utenti. E’ come se i programmatori avessero fatto tutto solo per sè stessi (Sono cambiate le API ? A chi importa ? Sembra rimasto tutto uguale a me). La caratteristica migliore è l’auto aggiornamento. Avevo smesso di aggiornare Joomla dal momento che ogni volta incontravo qualche problema. Il passaggio alla 1.5 mi aveva costretto al copia-incolla dei miei articoli dal momento che qualcosa era andato storto con lo strumento di migrazione. Non dev’essere così. Anche se è software open source gratuito, dovrebbe essere utilizzabile da persone che non passano il loro tempo a scartabellare nella documentazione per cercare la formula magica. WordPress è un’altra storia. Ciò nonostante fornisce tutti i livelli necessari di personalizzazione per trasformare il tuoi sito in un complesso CMS.
Mentre cercavo un tema adatto, mi sono imbattuto in Thesis. Non è solo un tema. E’ un framework. Aggiunge un gran numero di opzioni e mantiene tuttavia la flessibilità per renderlo ciò che vuoi. Attraverso gli “hooks” si può personalizzare sia il comportamento che il layout delle pagine. Date un’occhiata a questo articolo. In breve tempo sono stato in grado di raggiungere questo risultato. Sono molto contento di Thesis e aggiornerò appena possibile anche il mio sito.
P.S. L’auto salvataggio evita spiacevoli incovenienti !
At last I’ve managed to replace Joomla with WordPress. And I’m not going back. WordPress is simply easier, prettier and faster. Whatever you do, whatever you goal maybe it’s definitely The Choice. Each new release brings new options, more eye-candies and time saving features. Moving from Joomla 1.0 to 1.5 brought nothing really rewarding to mere users. It’s as if programmers wrote just for themselves (APIs change ? Who minds ? Everything looks the same to me). The more wonderful feature of WordPress anyway is automatic update. I had stopped updating Joomla since each time I ran into some problems. Moving to 1.5 simply compelled me to copy and paste my posts since something didn’t go the right way with migrator tool. It’s not supposed to be this way. Even if it’s free open source software, it should be usable even by people who don’t spend their time digging into docs to find the magic formula. WordPress is really another story. Nevertheless it provides all levels of customization necessary to turn your website into a complex CMS.
While searching for a suitable theme, I’ve come across Thesis. It’s not only a theme. It’s a framework. It adds a large number of options and yet it holds the flexibility to make it look the way you like. By means of hooks, you can customize behaviour and layout of your pages. See this post for further explanations. In a short time I was able to achieve this result. I’m very happy with Thesis and I’m working to adapt this website as soon as possible.
P.S. Autosave is really cool !

 
2 Comments

Pubblicato da su agosto 6, 2009 in Uncategorized

 

Rifugio Benigni, valle d'Inferno e ritorno

Due mesi dopo la salita al Resegone, approfittando dell’assenza delle due bimbe in vacanza dai nonni, decidiamo di regalarci una gita in quota. La scelta cade sul rifugio Benigni da Cusio: due ore per 700m di dislivello: fattibile anche senza allenamento. Ma la sorpresa e’ dietro l’angolo: poco fuori Cusio, lungo la strada che sale ai piani dell’Avaro, incontriamo le indicazioni per l’agriturismo Ferdi in Val d’Inferno. L’idea ci solletica. Un bel giro ad anello passando a gustare qualche delizia d’alpeggio e’ proprio quel che ci vuole per una giornata da ricordare. Lasciata la macchina al solito tornante saliamo tranquillamente verso il rifugio.
Dudu nello zainetto ci assilla con mille richieste: pello (cappello), puccio (il cappuccio dello zainetto), goffe (il golf per quando ha freddo), acqua, ca(l)do, puia (paura di qualsiasi cosa, dalla marmotta al burrone). Dopo aver perso il cappello tranquillizza la madre con “fa niente dai mamma calma”. Mitico. Lungo il percorso incontriamo numerose lingue di neve, alcune anche da un metro e mezzo di spessore. Riscaldamento globale… mah.
Al rifugio (2222m) chiediamo informazioni sulla strada e dopo un’oretta di sosta ripartiamo lungo il sentiero 101. Passata la bocchetta di Val Pianella (2224m) procediamo in salita fino a raggiungere la cima di Giarolo (2314m) che ci ricompensa con una bellissima vista sulla Val Gerola. Riprendiamo in discesa lungo un canalone che infine ci porta alla testa della Val D’Inferno (1,5 ore dal Benigni).
Dopo un pediluvio ristoratore puntiamo decisi al Ferdi (1 ora) e qui tra una torta e l’altra ci informiamo sul ritorno. Le possibilità sono due. La prima e’ quella di seguire la strada sterrata fino al bivio per le Cinque Vie, salire alla Casera del Valletto (400m di dislivello, 1.20 h) e ritornare dal sentiero dell’andata. La seconda e’ quella di seguire tutta la strada sterrata verso sinistra, ignorando le deviazioni per Ornica per arrivare sopra Cusio lungo la strada dell’Avaro (1,5 ore, 200m di dislivello). Scegliamo questa seconda pur sapendo che senza passaggio in auto mi toccherà poi risalire altri 300m su strada per riprendere la macchina. Ma ho fiducia e faccio bene: al primo tentativo di autostop vengo prelevato da un autoctono di Olmo. Grazie, ero proprio morto! Sette ore con Dudu sulle spalle si sentono. Ma siamo agli sgoccioli: l’anno prossimo camminerà anche lui.

 
Leave a comment

Pubblicato da su luglio 26, 2009 in Uncategorized

 

Medialayer rocks !

After searching for a while a host which could keep up with my expectations, I finally got into this article which led me to the (hopefully) right choice. In the meantime I went through several blogs, reviews, advices and so on which were contradictory and misleading. The real problem in picking up the right host is that there’s no way to select the right criteria for googling. Generally I start by searching how many occurencies I can find for ‘hostofmydreams SUCKS’ versus ‘hostofmydreams ROCKS’. It’s a dead end path. A good ratio is 1 to 10 but it’s not that easy when you find more the a thousand pages stating that hostofyourdreams is a crap. In addition there are websites whose only purpose is to debate about a single host. Reviews are totally useless since they’re generally written by people who are paid by the same hosts they revise. To make things more complicated, I’ve found that even on wordpress.org hosts suggested are unreliable.I checked Bluehost, Dreamhost, GoDaddy, AN Hosting and many others. Media Temple was the most promising but some posts pointed out that it had its own problems. So I’ve finally got here. MediaLayer is not one of the cheapest around but as long as I can tell it’s really really fast. I’m from Italy and their server is in Chicago. Pages load even faster than with my previous (expensive) italian server. SSH, shared SSL, unlimited emails, unlimited ftp accounts, 500MB of disk space and 10 GB/month of bandwidth for 10$/month. Let’s see how long my honeymoon lasts.Dopo aver cercato per un po’ un host che incontrasse le mie attese, mi sono imbattuto in questo articolo che mi ha portato alla scelta (spero) finale. Nel frattempo ho letto un sacco di articoli, blog e recensioni che erano contradditorie e fuorvianti. Il vero problema nello scegliere il server giusto è selezionare i criteri di ricerca in Google. In genere metto a confronto il numero di risultati di ‘ilserverdeimieisogni ROCKS’ contro ‘ilserverdeimieisogni SUCKS’. E’ una via senza uscita. Un buon rapporto è 1 a 10 ma è comunque difficile scegliere se un migliaio di pagine sostengono che l’host dei tuoi sogni è uno schifo. In aggiunta ci sono siti web che discutono di un solo server. Le recensioni sono inutili dal momento che sono scritte da gente pagata dagli host che recensiscono. A rendere le cose più complicate ci si mette pure wordpress.org che suggerisce host inaffidabili.
Ho verificato Bluehost, Dreamhost, GoDaddy, AN Hosting e molti altri. Media Temple era il più promettente ma alcuni post evidenziavano alcuni problemi particolari. Alla fine sono arrivato qui. MediaLayer non è uno dei più a buon mercato che si possono trovare in giro ma per quello che posso dire finora è veramente veloce. Scrivo dall’Italia ed il server è a Chicago. Le pagine caricano più velocemente di quelle servite dal mio precedente (e costoso) server italiano. SSH, SSL condiviso, email illimitate, account ftp illimitati, 500MB di spazio e 10 GB al mese di banda per 10$/mese. Vediamo quanto dure questa luna di miele.

 
Leave a comment

Pubblicato da su giugno 4, 2009 in Uncategorized

 
 
Iscriviti

Get every new post delivered to your Inbox.