Tuesday, March 30, 2010

Igy kell megkeresni az NSDocumentDirectory-t

innen

Locating Directories as Paths

The following example illustrates how you can use the NSSearchPathForDirectoriesInDomains function to find the current user’s Documents directory:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
    NSString *userDocumentsPath = [paths objectAtIndex:0];
    // Implementation continues...

NSSearchPathForDirectoriesInDomains simply returns the path of the appropriate directory, it does not guarantee that the directory exists. If you want to perform operations such as writing to the directory, you may have to create it first.

Monday, March 29, 2010

Refresh UITableView UIActivityIndicatorView hasznalataval

Olyasmit akartam csinalni, mint a Mail app-ban, hogy egy refresh gomb megnyomasara elkezdporogni az UIActivityIndicatorView a toolbarban, majd amikor sikerult frissiteni a szerverrol akkor visszakerul a refresh gomb. (A Mail app-ban nem tunik el a refresh gomb, de nalam igen.)

A UIViewController toolBarItems-e egy NSArray amiben a UIView-k vannak. Ugy lehet ezeket egymastol egyenlo tavolsagra tenni, ha beteszunk kozejuk olyan UIBarButtonItem-eket amiket UIBarButtonSystemFlexibleSpace-kent inicializalunk.

Elsore ugy probaltam, hogy refreshButton push-aba akartam meghivni egymas utana toolbar atvaltoztatasat, a szerverrol valo adatlekerest es a toolbar visszavaltoztatasat, ami azert se volt jo megoldas, mert ez leblokkolta volna az alkalmazast es azert sem, mert igy nem valtozott a toobar sem. Ehelyett megvaltoztatom a toolbart es egy masik thread-ben kommunikalok a szerverrel majd frissitem a tableview-t es a toolbart.


DryIcons.com - ingyenes ikonok

Itt.

Icon mellett lathato kis szam (badgeNumber) beallitasa

[[UIApplication sharedApplication] setApplicationIconBandgeNumber:42];

Tuesday, March 2, 2010

UIBarButtonItem title-jenek beallitasa

Ha a initWithBarButtonSystemItem:target:action:-nel inicializaljuk a UIBarButtonItem-et, akkor utana a setTitle nem valtoztatja meg a title-jet, ezert inkabb a initWithTitle:style:target:action:-t kell hasznalni.

Monday, March 1, 2010

NSDate to NSString

Az NSDateFormatter segitsegevel igy:

NSDate *now = [NSDate date];

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];

[dateFormat setDateStyle:NSDateFormatterFullStyle];

NSString *s = [dateFormat stringFromDate:now];

[dateFormat release];

Persze ha a setDateStyle helyett a setDateFormat-ot hasznajuk akkor a Date Formatter lehet sokfele, peldaul:
"MM.dd.yyyy. hh:mm" > "03.01.2010"
"MM/dd/yyyy hh:mma" > "03/01/2010 04:20PM"
Vagy a setDateStyle-nal maradva az NSDateFormatterStyle-bol hasznalhatjuk barmelyiket.