레이블이 sqlite인 게시물을 표시합니다. 모든 게시물 표시
레이블이 sqlite인 게시물을 표시합니다. 모든 게시물 표시

2016년 4월 3일 일요일

iOS 개발시 사용한 sqlite 데이터베에스 파일을 mac으로 가져오려면?

https://github.com/FahimF/SQLiteDB

를 이용해서 app에서  swift언어와 함께 sqlite를 손쉽게 이용할 수 있다.

어떠한 문제에 의해서 앱에서 저장되는 데이터를 mac에서 분석 해야 하는 일이 생길 수 있다.

sqlite3를 이용해서 터미널에서 .db 파일을 생성 하고 ( 테이블 스키마 구성)
해당 파일을 프로젝트에 추가 하여 앱을 작성 하면
해당 데이터베이스 파일은 앱과 함께 아이폰 디바이스에 들어가서 동작 한다.

앱이 특정 작업을 수행하면서 데이터베이스를 갱신하고 많은 일을 처리 한다음
해당 데이터베이스 파일을 다시 맥으로 가져오고 싶을 때

itunes에서 해당 앱을 선택 하면 데이터베이스 파일이 보이고 손쉽게 내려 받을 수 있는
방법이 필요 하다.

itune에 연결하면 도큐먼트 파일이 보이는 앱은 어떻게 만드는가?



info.plist에 위와 같이 Application support iTunes file sharing YES 로 설정 하면 끝이다.

info.plist 파일을 source code로 열면 다음과 같다.
<key>UIFileSharingEnabled</key>
<true/>

이렇게 info.plist를 수정한 앱을 수행시키고 itunes에 연결 하면 해당 앱을 선택 하면 sqlite 데이터 베이스 파일이 보이고 itunes를 통해서 내려 받을 수 있다.


2015년 2월 2일 월요일

iOS 팁 여러개( sqlite, html, adhoc distribute, NSNotificationCenter, UIColor rgb

sqlite 테이블 리스트 보기

select name from sqllite_master where type ='table';

html text를 lalbel에 보이게 하려면

NSString *htmlString =[NSString stringWithFormat:@"%@", [[self.arrMessageData objectAtIndex:indexPath.row] objectAtIndex:indexOfMessage]];
    NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
   cell.messageLabel.attributedText = attributedString;

html을 일반 plain text로 변경 하려면

- (NSString *)flattenHTML:(NSString *)html {
 
    NSScanner *theScanner;
    NSString *text = nil;
    theScanner = [NSScanner scannerWithString:html];
 
    while ([theScanner isAtEnd] == NO) {
     
        [theScanner scanUpToString:@"<" intoString:NULL] ;
     
        [theScanner scanUpToString:@">" intoString:&text] ;
     
        html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
    }
 
    html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
 
    return html;
}


adhoc 배포

http://blog.saltfactory.net/242

드랍박스에 디렉토리를 만들고
거기에 ipa 파일  아카이브 할때 adhoc으로 한다.
물론 이에 필요한 provisioning이 필요 하다.
이렇게 해서 생성한 ipa파일과
.plist 파일이 필요 하다.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://드랍박스 .ipa링크를 생성해서 붙인다.</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.ssomon.InaschoolTeacher</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>InaschoolTeacher</string>
</dict>
</dict>
</array>
</dict>
</plist>



<a href="itms-services://?action=download-manifest&url=드랍박스 plist의 링크를 붙여서 html
파일을 만든다.
www.ropbox.com -> dl.dropboxusercontent.com 으로 변경 한다.







객체간 자료 전송 

http://blog.naver.com/iss6388/10183297308
--> 노티가 왓을때 다른 viewController에게 알리는 코드를 응용 할수 있다.
NSNotificationCenter postNotificationName으로 전송 (NSDictionary를 전송하고)

이를 다른 ViewController에서 받아서 처리 하도록 한다.

전송 예제
    [[NSNotificationCenter defaultCenter]
     postNotificationName:@"UIApplicationDidReceiveRemoteNotification"
     object:self

     userInfo:nil];

받는곳
viewDidLoad에서 등록
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(didReceiveRemoteNotification:)
     name:@"UIApplicationDidReceiveRemoteNotification"
     object:nil];

viewDidUnload에서 해제
    [[NSNotificationCenter defaultCenter]
     removeObserver:self
     name:@"UIApplicationDidReceiveRemoteNotification"
     object:nil];

이렇게 하면 UiApplicationDidReceiveRemoteNotification이 호출 된다.


rgb 칼라를 UICrolro 매크로

http://winplz.tistory.com/entry/UIColor-간단히-Macro로-사용하기
#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]

cell.textLabel.textColor = RGB(0x60,0x60,0x60);


2015년 1월 23일 금요일

sqlite를 iOS app에 이용하기 위한 방법 정리

알바 하며 얻은 내공들을 기록 한다.
알바로 하면 급하게 지식을 습득한다.
그냥 취미 삼아 할 때와 다르게 일정과 시간에 쪼들리며 결국은 해답을 찾게 되어 있다.


sqlite 스키마 보기

SELECT sql FROM sqlite_master WHERE name = 'tablename';

sqlite 프롬프트 나가기 

.exit

primary key

id integer primary key 라고 만들고 데이터를 넣지 않고 insert 하면
자동으로 증가 하며 insert 한다.

tableview custom cell 작업

http://www.ioscreator.com/tutorials/customize-tableviewcells-with-storyboards

sqlite와 tableview 연동 샘플 코드

http://www.appcoda.com/sqlite-database-ios-app-tutorial/

sqlite api의 리턴 값을 BOOL 변수로 받아 오류가 있다.
int로 리턴 값을 받아야 올바르게 동작 한다.