appDelegate = (WeatherAppDelegate *)[[UIApplication sharedApplication] delegate];

Wrapper 클래스 사용시

http://theeye.pe.kr/entry/http-wrapping-class-with-iphone-network-programming





[헤더파일]
    // Google Weather Service
    NSMutableData *responseData;  //서버로부터 받은 자료를 담는 변수
    NSURL *theURL;
   
    // Information
    NSString *location;
    NSString *date;
   
    // Current Conditions
    UIImage *icon;
    NSString *temp;
    NSString *humidity;
    NSString *wind;
    NSString *condition;
   
    // Forecast Conditions
    NSMutableArray *days;
    NSMutableArray *icons;
    NSMutableArray *temps;
    NSMutableArray *conditions;


[소스파일]
- (void)queryService:(NSString *)city withParent:(UIViewController *)controller {
    viewController = (MainViewController *)controller;
    responseData = [[NSMutableData data] retain];
   
    NSString *url = [NSString stringWithFormat:@"http://www.google.com/ig/api?weather=%@", city];    //서버url을 적는다.
    theURL = [[NSURL URLWithString:url] retain];
    NSURLRequest *request = [NSURLRequest requestWithURL:theURL];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];
}

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse {
    [theURL autorelease];
    theURL = [[request URL] retain];
    return request;
}

// 서버로 부터 답변이 처음 오면 호출된다. 자료는 없다.
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [responseData setLength:0];
}
    
// 서버로 부터 데이터를 받으면서 계속 호출된다. responseData에 계속 추가한다.
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}
    
// 에러가 발생하면 호출된다.
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    // Handle Error
}

// 모든 응답이 오고나서 연결이 해제되면 호출된다.
// responseData에 있는 자료를 사용하면 된다.
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
   
    //NSString *content = [[NSString alloc] initWithBytes:[responseData bytes] length:[responseData length] encoding:NSUTF8StringEncoding];
    //NSLog( @"Data = %@", content );
   
    days = [[NSMutableArray alloc] init];
    icons = [[NSMutableArray alloc] init];
    temps = [[NSMutableArray alloc] init];
    conditions = [[NSMutableArray alloc] init];
   
    NSString *xpathQueryString;
    NSArray *nodes;

    // Forecast Information
    // NSString *location;
    xpathQueryString = @"//forecast_information/city/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
               location = [node objectForKey:key];
            }
        }
    }
    NSLog(@"location = %@", location);
   
    // NSString *date;
    xpathQueryString = @"//forecast_information/forecast_date/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                date = [node objectForKey:key];
            }
        }
    }
    NSLog(@"date = %@", date);   

    // Current Conditions
    // UIImage *icon;
    xpathQueryString = @"//current_conditions/icon/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                icon = [NSString stringWithFormat:@"http://www.google.com%@", [node objectForKey:key]];
            }
        }
    }
    NSLog(@"icon = %@", icon);
   
    // NSString *temp
    NSString *temp_f;
    NSString *temp_c;
    xpathQueryString = @"//current_conditions/temp_f/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    //NSLog( @"nodes = %@", nodes );
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                temp_f = [node objectForKey:key];
            }
        }
    }
    xpathQueryString = @"//current_conditions/temp_c/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    //NSLog( @"nodes = %@", nodes );
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                temp_c = [node objectForKey:key];
            }
        }
    }
    temp = [NSString stringWithFormat:@"%@F (%@C)", temp_f, temp_c];
    NSLog(@"temp = %@", temp);   
   
    // NSString *humidity;
    xpathQueryString = @"//current_conditions/humidity/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                humidity = [node objectForKey:key];
            }
        }
    }
    NSLog(@"humidity = %@", humidity);

    // NSString *wind;
    xpathQueryString = @"//current_conditions/wind_condition/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                wind = [node objectForKey:key];
            }
        }
    }
    NSLog(@"wind = %@", wind);

    // NSString *condition
    xpathQueryString = @"//current_conditions/condition/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);
    for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                condition = [node objectForKey:key];
            }
        }
    }
    NSLog(@"condition = %@", condition);
       
    // Forecast Conditions
    //NSMutableArray *days;
    xpathQueryString = @"//forecast_conditions/day_of_week/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);   
     for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                [days addObject:[node objectForKey:key]];
            }
        }
    }
    NSLog(@"days = %@", days);
   
    //NSMutableArray *icons;
    xpathQueryString = @"//forecast_conditions/icon/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);   
     for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                [icons addObject:[NSString stringWithFormat:@"http://www.google.com%@", [node objectForKey:key]]];
            }
        }
    }
    NSLog(@"icons = %@", icons);
   
    //NSMutableArray *temps;
    NSMutableArray *highs = [[NSMutableArray alloc] init];
    NSMutableArray *lows = [[NSMutableArray alloc] init];
   
    xpathQueryString = @"//forecast_conditions/high/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);   
     for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                [highs addObject:[node objectForKey:key]];
            }
        }
    }
    xpathQueryString = @"//forecast_conditions/low/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);   
     for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                [lows addObject:[node objectForKey:key]];
            }
        }
    }
    for( int i = 0; i < highs.count; i++ ) {
        [temps addObject:[NSString stringWithFormat:@"%@F/%@F", [highs objectAtIndex:i], [lows objectAtIndex:i]]];
    }
    NSLog(@"temps = %@", temps);
    [highs release];
    [lows release];
   
    //NSMutableArray *conditions;
    xpathQueryString = @"//forecast_conditions/condition/@data";
    nodes = PerformXMLXPathQuery(responseData, xpathQueryString);   
     for ( NSDictionary *node in nodes ) {
        for ( id key in node ) {
            if( [key isEqualToString:@"nodeContent"] ) {
                [conditions addObject:[node objectForKey:key]];
            }
        }
    }
    NSLog(@"conditions = %@", conditions);
   
    [viewController updateView];
}

- (NSString *) copyDatabaseToDocuments {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppdendingPathComponent:@"dbfile.sqlite"];

if ( ![fileManager fileExistsAtPath:filePath] ) {
NSString *bundlePath = [ [ [NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"dbfile.sqlite"];
[fileManager copyItemAtPath:bundlePath toPath:filePath error:nil];
}
return filePath;
}

http://www.pcraft.kr/145

https://github.com/mocra/fmdb-migration-manager


https://github.com/ccgus/fmdb
맥에서
프로젝트 생성할 폴더로 이동 후

git clone [github 사이트에서 제공하는 url]

[fmdb를 불러오는 예]
git clone https://github.com/ccgus/fmdb.git

을 하면 최신으로 파일을 가져온다

Apple has introduced a new .plist file format in 10.4. You'll notice that you can no longer just edit a .plist file in TextEdit or other text editors. The reason for this is that the files are now binary rather than raw XML.

Luckily for us, there is a command line utility called plutil that can convert back and forth between the two formats. You can convert the .plist file you want to edit to XML format, edit it in TextEdit, then convert back to binary for use. To convert a binary .plist file to XML format for editing, type this in the Terminal:
plutil -convert xml1 some_file.plist
To convert an XML .plist file to binary for use:
plutil -convert binary1 some_other_file.plist
Replace some_file.plist and some_other_file.plist with the actual filenames, obviously...


plutil -convert xml1 filename.plist : 바이너리를 xml로 만들어 줍니다.

plutil -convert binary1 filename.plist : xml을 바이너리로 만들어 줍니다.

변환시 파일 자체가 바뀌니 백업은 미리 해놓으면 좋습니다.

 

출처 : http://www.hopark.info/?p=80

1.

맥 OS X을 새 하드 디스크에 설치했다면, 루트 계정이 안 만들어져 있습니다.
따라서 맥 오에스 텐 안에서 터미널 열어서
$ 프롬프트 상태에서 su 명령을 내려도 암호가 맞을 리가 없으므로 su 명령을 사용할 수 없습니다.

이럴 때는 재부팅할 필요 없이, 응용 프로그램 안에 있는 터미널을 실행하여, $ 프롬프트 상태에서

sudo -s <엔터>
자신의 계정 암호<엔터> (이때 계정이 관리자 등급 계정이어야 함)

그러면 # 프롬프트로 바뀝니다. 여기서

passwd root<엔터>
root 계정에 사용할 암호를 입력하고 <엔터> 확인을 위해서 한번 더 같은 암호 넣고 <엔터>

이제부터는 터미널에서 su 명령을 사용할 수 있죠.

2.

다음은 이미 설정해 놓은 루트 계정 암호를 잊어버렸을 경우에 새로 설정하는 방법입니다.

싱글 유저 모드로 부팅하기 : 맥 오에스 텐을 재시동하게 하고, 화면이 검게 변화면 command+s 키를 동시에 누르고 있으면, 평소에 기본적으로 시동되는 멀티 유저 모드가 아닌 싱글 유저 모드로 부팅됩니다.

검은 바탕에 흰 글씨로 된 텍스트 시동 화면이 나오면서 잠시 후 프롬프트(root #_)가 나타납니다. 이때, 프롬프토 바로 윗줄에 두 가지 중요한 명령어가 표시되어 있습니다.

/sbin/fsck -fy (filesystem consistency check and interactive repair)

/sbin/mount -uw /


첫번째 명령인 “/sbin/fsck -fy”는 다음에 설명하고, 여기서는 두번째 명령인 “/sbin/mount -uw /”를 이용하여, 루트(root, 유닉스 OS에서 최상급 운영자 ID) 계정을 암호를 설정하거나 변경하는 방법만 설명하겠습니다.

두번째로 안내되어 있는 “/sbin/mount -uw /” 명령을 그대로(빈칸까지) 입력하고 엔터 키를 누릅니다.

다음으로 “passwd root”를 입력하고 엔터 키를 누릅니다.

그러면 루트 계정의 암호를 지정하거나 변경할 수 있습니다.

루트 계정의 암호 설정이 끝났으면, “reboot” 명령을 입력하고 엔터 키를 눌러, 일반적인 멀티 유저 모드로 재시동을 하면 됩니다.

참고로, root 계정의 암호를 지정했으면, 일반적인 맥 오에스 텐으로 시동한 상태에서 터미널을 열어서 “su” 명령을 입력하면 암호를 묻는데, 여기서 root 계정의 암호를 입력하면, 사용자 계정으로 시동을 했더라도 루트 계정의 권한으로 터미널에서 명령을 내릴 수 있습니다.


http://three20.info







URL -   http://three20.info


Three20 Overview

Core

Think of core as your swiss-army knife of Objective-C development. You should take some time to familiarize yourself with its features.

With the Three20 Core you can

  • generate md5 hashes from NSData objects,
  • extend the logging and debug capabilities of Xcode,
  • compare two version strings (is 3.0 older than 3.1?),
  • create non-retaining NSArrays and NSDictionaries for delegate use,
  • strip HTML tags from strings,
  • safely add non-empty, non-nil strings to NSDictionaries,
  • and format dates in relative time (5 hours ago).

You'll find all of these methods in the Three20 Xcode project in the
Global => Core and Global => Additions => Core groups.

Network

If you're building an app that uses a web-based API, Three20's Network component is going to make your job easier. Three20 supports disk and memory network caching. There is also a layer built upon requests that makes it easy to process the response data.

UI

A growing set of common views and controllers is available within the Three20 UI. The well-known Facebook photo browser/thumbnail viewer is one such controller.

+ Recent posts