{"id":1750,"date":"2012-08-27T12:57:07","date_gmt":"2012-08-27T12:57:07","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=1750"},"modified":"2017-01-27T15:19:33","modified_gmt":"2017-01-27T06:19:33","slug":"ios-%eb%b0%94%ec%9d%b4%eb%84%88%eb%a6%ac-%ed%8c%8c%ec%9d%bcbinary-file-%ec%93%b0%ea%b3%a0-%ec%9d%bd%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=1750","title":{"rendered":"[iOS] \ubc14\uc774\ub108\ub9ac \ud30c\uc77c(Binary File) \uc4f0\uace0 \uc77d\uae30"},"content":{"rendered":"<p>iOS\uc5d0\uc11c \ubc14\uc774\ub108\ub9ac \ud30c\uc77c\uc744 \uc0dd\uc131\ud558\uace0 \uc815\uc218, \uc2e4\uc218 \uadf8\ub9ac\uace0 \ubb38\uc790\uc5f4 \uac12\uc744 \uc21c\uc11c\ub300\ub85c \uc4f4 \ud6c4\uc5d0 \ub2e4\uc2dc \uc77d\uae30 \uc704\ud55c \ucf54\ub4dc\uc5d0 \ub300\ud574 \uc815\ub9ac\ud574 \ubd05\ub2c8\ub2e4. Objective-C\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud30c\uc77c \uad00\ub828 \ud074\ub798\uc2a4\ub97c \uc0ac\uc6a9\uc744 \uc2dc\ub3c4\ud588\uc73c\ub098 Ansi-C\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud30c\uc77c\ucc98\ub9ac \ud568\uc218\ub97c \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4. \uc9c4\uc815 &#8216;\uad6c\uad00\uc774 \uba85\uad00&#8217;\uc785\ub2c8\ub2e4 !!<\/p>\n<div><\/p>\n<div>UI \uc0c1\uc5d0 \uc815\uc218, \uc2e4\uc218 \uadf8\ub9ac\uace0 \ubb38\uc790\uc5f4\uc744 \uc785\ub825\ubc1b\ub294 \ud14d\uc2a4\ud2b8\ud544\ub4dc \ucee8\ud2b8\ub864\uc744 \ucd94\uac00\ud558\uc5ec UI\ub97c \uad6c\uc131\ud569\ub2c8\ub2e4. \uadf8 \ud654\uba74\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/div>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/1\/1057395790.png\" class=\"aligncenter\" width=\"354\" height=\"496\" alt=\"\uc0ac\uc6a9\uc790 \uc0bd\uc785 \uc774\ubbf8\uc9c0\" \/><\/div>\n<div>\uc5ec\uae30\uc11c Save \ubc84\ud2bc\uc744 \ud074\ub9ad\ud588\uc744\ub54c \uc785\ub825\ub41c \uac12\ub4e4\uc744 \ubc14\uc774\ub108\ub9ac \ud30c\uc77c\uc5d0 \uc800\uc7a5\ud558\ub294 \ucf54\ub4dc \uc608\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/div>\n<div>\n<pre>\r\n    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,\r\n                                                         NSUserDomainMask,\r\n                                                         YES);\r\n    NSString *documentDir = [paths objectAtIndex:0];\r\n    NSString *file = [documentDir stringByAppendingPathComponent:@\"mydata.bin\"];\r\n    const char *szFileName =  [file UTF8String];\r\n    FILE *pFile = fopen(szFileName, \"wb\");\r\n    if(pFile != NULL) {\r\n        int intValue = [tiInteger.text intValue];\r\n        fwrite((void *)&intValue, sizeof(intValue), 1, pFile);\r\n        \r\n        float floatValue = [tiFloat.text floatValue];\r\n        fwrite((void *)&floatValue, sizeof(floatValue), 1, pFile);\r\n\r\n        NSString *stringValue = tiString.text;\r\n        const char *bytesStringValue = [stringValue UTF8String];\r\n        int lenStringValue = strlen(bytesStringValue) + sizeof(int);\r\n        fwrite((void *)&lenStringValue, sizeof(lenStringValue), 1, pFile);\r\n        fwrite((void *)bytesStringValue, sizeof(char), lenStringValue, pFile);\r\n        \r\n        fclose(pFile);\r\n    }\r\n<\/pre>\n<p>iOS\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \ud30c\uc77c\uc744 \uc4f8 \uc218 \uc788\ub294 \ub514\ub809\ud1a0\ub9ac\ub97c \uc81c\ud55c\ud574 \ub193\uc2b5\ub2c8\ub2e4. \ud30c\uc77c\uc744 \uc4f8 \uc218 \uc788\ub294 \ub514\ub809\ud1a0\ub9ac\ub97c \uc5bb\uae30 \uc704\ud574 1\ubc88 ~ 5\ubc88 \ucf54\ub4dc\uac00 \uc0ac\uc6a9\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \ubb50&#8230; \ub098\uba38\uc9c0\ub294 fopen\uacfc fwrite\uc640 \uac19\uc740 \ud30c\uc77c \uc5f4\uae30 \ubc0f \uc4f0\uae30\uc5d0 \ub300\ud55c \uc77c\ubc18 C \ud568\uc218\ub97c \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4.<\/p><\/div>\n<div><\/div>\n<div>\ub2e4\uc74c\uc740 UI \uc911 Restore \ubc84\ud2bc\uc744 \ud074\ub9ad\ud588\uc744\ub54c \uc55e\uc11c Save \ubc84\ud2bc\uc5d0 \uc758\ud574 \uc800\uc7a5\ub41c \uac12\ub4e4\uc744 \ubcf5\uc6d0\ud558\ub294 \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/div>\n<div>\n<pre>\r\n    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,\r\n                                                         NSUserDomainMask,\r\n                                                         YES);\r\n    NSString *documentDir = [paths objectAtIndex:0];\r\n    NSString *file = [documentDir stringByAppendingPathComponent:@\"mydata.bin\"];\r\n    const char *szFileName =  [file UTF8String];\r\n    FILE *pFile = fopen(szFileName, \"rb\");\r\n    if(pFile != NULL) {\r\n        int intValue;\r\n        fread((void *)&intValue, sizeof(intValue), 1, pFile);\r\n\r\n        float floatValue;\r\n        fread((void *)&floatValue, sizeof(floatValue), 1, pFile);\r\n        \r\n        int lenStringValue;\r\n        fread((void *)&lenStringValue, sizeof(lenStringValue), 1, pFile);\r\n        \r\n        NSMutableData *data = [NSMutableData dataWithCapacity:lenStringValue];\r\n        char *bytesStringValue = (char *)[data bytes];\r\n        fread((void *)bytesStringValue, lenStringValue, 1, pFile);\r\n        \r\n        fclose(pFile);\r\n        \r\n        tiInteger.text = [NSString stringWithFormat:@\"%d\", intValue];\r\n        tiFloat.text = [NSString stringWithFormat:@\"%f\", floatValue];\r\n        tiString.text = [NSString stringWithUTF8String:bytesStringValue];\r\n    }\r\n<\/pre>\n<p>\uc800\uc7a5\ud588\ub358 \uac12\ub4e4\uc5d0 \ub300\ud574\uc11c \uc21c\uc11c\ub300\ub85c \uc77d\uc5b4 \uc624\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uc8fc\uc758\ud560 \uc810\uc740 \ubb38\uc790\uc5f4 \uac12\uc744 \uc77d\uae30 \uc704\ud574\uc11c char \ubc30\uc5f4\uc744 \uc0dd\uc131\ud558\uae30 \uc704\ud574 18\ubc88 ~ 19\ubc88 \ucf54\ub4dc\ucc98\ub7fc NSMutableData \ud074\ub798\uc2a4\ub97c \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4. Objective-C\ub294 new \uc5f0\uc0b0\uc790\ub97c \uc9c0\uc6d0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4 !!<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>iOS\uc5d0\uc11c \ubc14\uc774\ub108\ub9ac \ud30c\uc77c\uc744 \uc0dd\uc131\ud558\uace0 \uc815\uc218, \uc2e4\uc218 \uadf8\ub9ac\uace0 \ubb38\uc790\uc5f4 \uac12\uc744 \uc21c\uc11c\ub300\ub85c \uc4f4 \ud6c4\uc5d0 \ub2e4\uc2dc \uc77d\uae30 \uc704\ud55c \ucf54\ub4dc\uc5d0 \ub300\ud574 \uc815\ub9ac\ud574 \ubd05\ub2c8\ub2e4. Objective-C\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud30c\uc77c \uad00\ub828 \ud074\ub798\uc2a4\ub97c \uc0ac\uc6a9\uc744 \uc2dc\ub3c4\ud588\uc73c\ub098 Ansi-C\uc5d0\uc11c \uc81c\uacf5\ud558\ub294 \ud30c\uc77c\ucc98\ub9ac \ud568\uc218\ub97c \uc0ac\uc6a9\ud588\uc2b5\ub2c8\ub2e4. \uc9c4\uc815 &#8216;\uad6c\uad00\uc774 \uba85\uad00&#8217;\uc785\ub2c8\ub2e4 !! UI \uc0c1\uc5d0 \uc815\uc218, \uc2e4\uc218 \uadf8\ub9ac\uace0 \ubb38\uc790\uc5f4\uc744 \uc785\ub825\ubc1b\ub294 \ud14d\uc2a4\ud2b8\ud544\ub4dc \ucee8\ud2b8\ub864\uc744 \ucd94\uac00\ud558\uc5ec UI\ub97c \uad6c\uc131\ud569\ub2c8\ub2e4. \uadf8 \ud654\uba74\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. \uc5ec\uae30\uc11c Save \ubc84\ud2bc\uc744 \ud074\ub9ad\ud588\uc744\ub54c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=1750\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[iOS] \ubc14\uc774\ub108\ub9ac \ud30c\uc77c(Binary File) \uc4f0\uace0 \uc77d\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[91,92],"class_list":["post-1750","post","type-post","status-publish","format-standard","hentry","category-programming","tag-ios","tag-objective-c"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/1750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1750"}],"version-history":[{"count":1,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions"}],"predecessor-version":[{"id":3039,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/1750\/revisions\/3039"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1750"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}