336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요. 개발자 myoung입니다.

개발을 완료 한 후 정말 역사적으로 앱스토어에 앱을 올릴려고 하는데 ENABLE_BITCODE 오류가 나서 당황할때가 있습니다.

그냥 개발을 할때는 문제가 없는데 말입니다.ㅠㅠ 이럴때는 당황하시지 말고

'Build Settings'에 있는 'Enable Bitcode'를 YES로 바꿔주시면 됩니다.


반대로 이런 오류가 난다면

You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64...

'Enable Bitcode' 옵션을 NO로 해주시면 됩니다.


BitCode 란?

Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store. For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode


비트 코드는 컴파일  프로그램의 중간 표현입니다비트 코드를 포함하면 아이튠즈 커넥트에 업로드앱은 컴파일 저장소에 연결됩니다비트 코드를 포함하면 애플 스토어에 앱의  버전을 제출할 필요 없이 미래에  바이너리를 다시 최적화할  있고iOS 앱의 경우 비트 코드 옵션은 선택 사항이고, watchOS  tvOS 앱의 비트 코드가 필수로 적용되어야 한다.  - iOS Developer Library



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요 개발자 myoung 입니다. Swift 기준으로 설명을 하겠습니다.


URL nil 오류 나는 문제에 대해서 해결 방안을 알아보겠습니다.

보통 URL을 정의 할때는 이렇게 정의를 합니다.

1
2
let urlPath: String = "www.naver.com"
let url: NSURL = NSURL(string: urlPath)!
cs

물론 URL 자체가 비어 있어서 nil오류가 나는 경우도 있지만 주소 자체에 한글이 포함된 경우 nil 오류가 나는 경우가 있습니다.

그런경우 해결 방법은

1
2
3
4
let str_temp = "http://devsc.tistory.com/admin/entry/post/한글"
let str_url = str_temp.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())!
 
let url: NSURL = NSURL(string: str_url)!
cs

이런식으로 String URLQueryAllowedCharacterSet을 통해 인코딩을 하면 간단하게 해결됩니다.


궁금한점이나 오류가 있으면 댓글을 달아주세요 :)



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요. 개발자 myoung 입니다. 

오늘은 저장하고 싶은 이미지를 사진 앱에 노출이 될수 있도록 저장하는 방법에 대해서 알아보겠습니다.

다른 특별한 옵션을 주지 않고 단순하게 사진을 저장할때 사용 할수있는 방법입니다.

생각보다 너무 간단하고 한줄로 끝납니다.


(Obejctive-C)

1
2
3
4
5
6
7
8
9
10
11
//필요한 부분에서 호출
UIImageWriteToSavedPhotosAlbum(your_image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    if (error) {
        NSLog(@"error: %@", [error localizedDescription]);
    } else {
        NSLog(@"saved");
    }
}
cs


(Swift)

1
2
3
4
5
6
7
8
9
10
11
12
//필요한 부분에서 호출
UIImageWriteToSavedPhotosAlbum(img, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
 
func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) { 
       //사진 저장 한후
       if let error = error {
           // we got back an error!
           Toast(message: error.localizedDescription).show()  
       } else {
            // save    
       }
}
cs


궁금한점이나 틀린점이 있으면 언제든지 댓글을 달아 주세요. :)



'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)텍스트 위치 가져오기  (0) 2016.10.10
iOS)무음에서 소리 나오게 하기  (0) 2016.07.19
iOS)디바이스 정보 가져오기  (0) 2016.06.08
iOS)딕셔너리 키값 정렬 하기  (0) 2016.06.06
iOS)랜덤 함수  (0) 2016.05.26
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요. 개발자 myoung 입니다.

오늘은 iOS의 사용자 기기이름, 버전등을 가지고 올때 사용하는 currentDevice에 대해서 포스팅 하겠습니다.

애플 문서를 보게 되면

1
2
3
4
5
6
7
public var name: String { get } // e.g. "My iPhone"
public var model: String { get } // e.g. @"iPhone", @"iPod touch"
public var localizedModel: String { get } // localized version of model
public var systemName: String { get } // e.g. @"iOS"
public var systemVersion: String { get } // e.g. @"4.0"
public var orientation: UIDeviceOrientation { get } 
// return current device orientation.  this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.
cs


UIDevice 하위에 포함되어 있는 메소드 이며, 현재 디바이스에 대한 정보를 리턴해주는 메소드 입니다.

단일 객체로 이름, 모델, 모델의 지역 버전, 시스템이름, 시스템버전,  디바이스 현재 방향 String 객체를 리턴해주는 것을 알 수 있습니다.

이런식으로 사용 하시면 됩니다.


(Objective-C)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
NSLog(@"%@", [UIDevice currentDevice].name);
NSLog(@"%@", [UIDevice currentDevice].model);
NSLog(@"%@", [UIDevice currentDevice].localizedModel);
NSLog(@"%@", [UIDevice currentDevice].systemName);
NSLog(@"%@", [UIDevice currentDevice].systemVersion);
NSLog(@"%ld", (long)[UIDevice currentDevice].orientation)
 
//결과 값
iPhone Simulator
iPhone
iPhone
iPhone OS
9.3
0
cs


(swift)

1
2
3
4
5
6
7
8
9
10
11
12
13
print(UIDevice.currentDevice().name)
print(UIDevice.currentDevice().model)
print(UIDevice.currentDevice().localizedModel)
print(UIDevice.currentDevice().systemName)
print(UIDevice.currentDevice().systemVersion)
print(UIDevice.currentDevice().orientation)
        
//결과 값
iPhone Simulator
iPhone
iPhone
iPhone OS
9.3
cs

궁금한 점이나 틀린 부분이 있다면 댓글을 남겨 주세요!



'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)무음에서 소리 나오게 하기  (0) 2016.07.19
iOS)사진첩에 사진 저장하기  (0) 2016.06.12
iOS)딕셔너리 키값 정렬 하기  (0) 2016.06.06
iOS)랜덤 함수  (0) 2016.05.26
iOS)TTS(Text-to-Speech) 사용하기.  (0) 2016.05.19
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



안녕하세요. 개발자 myoung입니다.

NSMutableDictionary, NSDictionary을 사용 할때 키값을 이용해서 필요한 값을 꺼내서 사용하는데, 전체 키값을 정렬해야 하는 상황이 있습니다.

그때 딕셔너리의 전체 키값을 가지고 와서 내림차순 또는 오름차순으로 정렬해주는  방법입니다.


(Obejctive-C)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
[dic setObject:@"2" forKey:@"key2"];
[dic setObject:@"1" forKey:@"key1"];
[dic setObject:@"4" forKey:@"key4"];
[dic setObject:@"3" forKey:@"key3"];
    
//오름차순
NSArray * arr_ascending = [dic keysSortedByValueUsingComparator: ^(id obj1, id obj2) {
    if ([obj1 integerValue] > [obj2 integerValue]) {
        return (NSComparisonResult)NSOrderedDescending;
    }
    if ([obj1 integerValue] < [obj2 integerValue]) {
        return (NSComparisonResult)NSOrderedAscending;
    }
    return (NSComparisonResult)NSOrderedSame;
}];
NSLog(@"%@", arr_ascending);
    
//내림 차순
NSArray * arr_descending = [dic keysSortedByValueUsingComparator: ^(id obj1, id obj2) {
    if ([obj1 integerValue] < [obj2 integerValue]) {
        return (NSComparisonResult)NSOrderedDescending;
    }
    if ([obj1 integerValue] > [obj2 integerValue]) {
        return (NSComparisonResult)NSOrderedAscending;
    }
    return (NSComparisonResult)NSOrderedSame;
}];
NSLog(@"%@", arr_descending);
cs



(Swift)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let dic = NSMutableDictionary()
        dic.setObject("2", forKey: "key2")
        dic.setObject("1", forKey: "key1")
        dic.setObject("4", forKey: "key4")
        dic.setObject("3", forKey: "key3")
        
print(dic)
        
let arr_key = dic.allKeys.sort {
    //오름차순
    //$0.compare($1 as! String, options: .NumericSearch) == .OrderedAscending
    
    //내림차순
    $0.compare($1 as! String, options: .NumericSearch) == .OrderedDescending
}
 
print(arr_key)
cs




'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)사진첩에 사진 저장하기  (0) 2016.06.12
iOS)디바이스 정보 가져오기  (0) 2016.06.08
iOS)랜덤 함수  (0) 2016.05.26
iOS)TTS(Text-to-Speech) 사용하기.  (0) 2016.05.19
iOS)iPhone 해상도  (0) 2016.05.09
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



일반 앱을 만들때는 쓸일이 별로 없을 것 같은 랜덤 함수지만 쓰임새가 아주 많은 함수입니다. 

숫자 10에 위치한 곳에 원하는 숫자를 넣어 주시면 됩니다. 

만약 10을 넣고 돌리시면 0~10까지 사이에서 랜덤하게 숫자가 randomIndex 변수에 저장됩니다.


(Objective-C)

1
int randomIndex = arc4random() % 10;
cs


(Swift)

1
let randomIndex : Int = Int(arc4random_uniform(10))
cs



'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)디바이스 정보 가져오기  (0) 2016.06.08
iOS)딕셔너리 키값 정렬 하기  (0) 2016.06.06
iOS)TTS(Text-to-Speech) 사용하기.  (0) 2016.05.19
iOS)iPhone 해상도  (0) 2016.05.09
iOS)단어 정의 사전으로 찾기  (0) 2016.05.04
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



오늘은 iOS 에서 사용 되는 기본 TTS(Text-to_Speech)에 대한 사용 설명 입니다.

잘 되어 있는 오픈소스도 많지만 기본으로 제공 되는 프레임워크를 통해 쉽게 구현 하실 수 있습니다.

TTS를 기본적으로 사용 하실려면 'AVFoundation'라는 프레임워크를 임포트 시켜 주셔야 됩니다. 

이제 Objective-C를 내려놓고 Swift를 사용 하는 시점이기 때문에 Swift를 통해 설명을 해 드리겠습니다.


밑에 코드를 보시면 AvSpeechSynthesizer를 통해 초기화를 해주시고나서

AVSpeechUtterance를 통해 TTS로 읽어줄 텍스트와 각 언어별로 지정을 해주고 rate를 통해 속도를 조절합니다. 

(저 같은 경우에는 0.4가 적당한 수치라고 느껴지는데 한번 수치를 다양한게 변경시켜서 앱 성격에 맞게 조절 해주시면 됩니다.)

AvSpeechSynthesizer로 초기화한 synthesizer의 speakUtterance 메소드를 통해 설정 해 놓은 AVSpeechUtterance 출력 시키면 됩니다.


(Swift)

1
2
3
4
5
6
7
let synthesizer = AVSpeechSynthesizer()

let utterance = AVSpeechUtterance(string: "your String")        
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
utterance.rate = 0.4
        
synthesizer.speakUtterance(utterance)
cs


(Objective-C)

1
2
3
4
5
6
7
AVSpeechSynthesizer * synthesizer = [[AVSpeechSynthesizer alloc]init];
    
AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc]initWithString:@"Your String"];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = 0.4f;
    
[synthesizer speakUtterance:utterance];
cs


(지원 가능한 언어 목록)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Arabic (Saudi Arabia) - ar-SA
Chinese (China) - zh-CN
Chinese (Hong Kong SAR China) - zh-HK
Chinese (Taiwan) - zh-TW
Czech (Czech Republic) - cs-CZ
Danish (Denmark) - da-DK
Dutch (Belgium) - nl-BE
Dutch (Netherlands) - nl-NL
English (Australia) - en-AU
English (Ireland) - en-IE
English (South Africa) - en-ZA
English (United Kingdom) - en-GB
English (United States) - en-US
Finnish (Finland) - fi-FI
French (Canada) - fr-CA
French (France) - fr-FR
German (Germany) - de-DE
Greek (Greece) - el-GR
Hindi (India) - hi-IN
Hungarian (Hungary) - hu-HU
Indonesian (Indonesia) - id-ID
Italian (Italy) - it-IT
Japanese (Japan) - ja-JP
Korean (South Korea) - ko-KR
Norwegian (Norway) - no-NO
Polish (Poland) - pl-PL
Portuguese (Brazil) - pt-BR
Portuguese (Portugal) - pt-PT
Romanian (Romania) - ro-RO
Russian (Russia) - ru-RU
Slovak (Slovakia) - sk-SK
Spanish (Mexico) - es-MX
Spanish (Spain) - es-ES
Swedish (Sweden) - sv-SE
Thai (Thailand) - th-TH
Turkish (Turkey) - tr-TR
cs

출처 : http://susemi99.kr/981



'iOS 프로그래밍 > iOS' 카테고리의 다른 글

iOS)딕셔너리 키값 정렬 하기  (0) 2016.06.06
iOS)랜덤 함수  (0) 2016.05.26
iOS)iPhone 해상도  (0) 2016.05.09
iOS)단어 정의 사전으로 찾기  (0) 2016.05.04
iOS)App 설정으로 이동하기  (0) 2016.05.03
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



iPhone 이 예전에는 4s/5/5s 기준으로만 개발을 하면 되었지만 작년 부터 6/6+가 추가되어 신경 써야 할 화면 크기가 늘었습니다. 

Autolayout을 쓰는 분들이라면 크게 문제가 안되겠지만 (결국 가로 세로 비율은 같습니다.) 

안쓰는 경우에는 매우 민감한 문제이기 때문입니다.

개발에서 사용되는 해상도는

  • 4/4s - 320*480
  • 5/5s - 320*568
  • 6/6s - 375*667
  • 6+/6s+ - 414*736

개발에 사용되는 해상도를 생각하시고 개발하면 나머지는 알아서 기기가 해주기 때문에 따로 설정을 안해주셔도 실제 해상도로 맞춰서 됩니다.
밑에 사진은 iPhone 2G 부터 iPhone 6+ 까지 개발 해상도 부터 실제 해상도 까지 나온 표입니다.


출처 : http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



특정 단어를 영어사전 또는 기타 사전으로 찾아서 결과를 보여주는 뷰컨트롤러 입니다.

영어단어, 회화 어플리케이션에서 여러모로 쓸모가 있을꺼 같습니다.

처음 창을 띄우면 아무 것도 나타나지 않습니다. 왼쪽 하단 밑에 관리에 들어가서 해당 언어를 다운 받으면 나타납니다.


(Objective-C)

1
2
UIReferenceLibraryViewController * ViewController = [[UIReferenceLibraryViewController alloc] initWithTerm:"찾고자 하는 단어"];
[self presentModalViewController:ViewController animated:YES];
cs


(Swift)

1
2
let ViewController = UIReferenceLibraryViewController(term: "찾고자 하는 단어")  
self.presentViewController(ViewController, animated: true, completion: nil)
cs



지원되는 언어 및 사전 종류

 



옵션이라는 단어를 찾으면 이런 결과를 보여줍니다.



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



iOS는 안드로이드와는 다르게 권한을 설치 할때 물어보는 것이 아니라 앱을 구동하면 물어서 권한을 획득합니다. 

문제는 권한을 실수로 사용자가 허용안함으로 했을때, 기능상 문제가 생길수 있는데 이럴때 iOS를 처음 다루거나 잘 모르시는 분들은 App이 문제가 생긴줄 알 수 있습니다. 

그럴 때는 알트창을 띄어 충분히 설명을 하고 설정에서 App에 대한 권한을 고칠 수 있는 곳으로 이동 시키면 될꺼 같습니다. 

생각보다 간단합니다. 이동을 원하는 곳에서 실행 시켜 주시면 됩니다.


(Objective-C)

1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@앱번들ID", UIApplicationOpenSettingsURLString]]];
cs


(Swift)

1
UIApplication.sharedApplication().openURL(NSURL(string: "\(UIApplicationOpenSettingsURLString)프로젝트앱번들ID")!)
cs



+ Recent posts