본문 바로가기
반응형

프로그래밍

Closure Memory leak with Retain Cycle Examples Objc typedef void (^MyBlock)(void); @property (nonatomic, copy) MyBlock block; - (void)viewdidLoad { [super viewDidLoad]; // Retain cycle self.block = ^{ NSLog(@"%@", self.title); }; // No retain cycle NSString *title = self.title; self.block = ^{ NSLog(@"%@", title); }; // No retain cycle @weakify(self); self.block = ^{ @strongify(self); if (!self) { return; } NSLog(@"%@", self.title); }; // No.. 더보기
python 버전 매니저 Install pyenv with brew to manage different Python versions: brew install pyenv List all installable versions with pyenv install --list Install Python 2.7.18 with pyenv install 2.7.18 List installed versions with pyenv versions Set global python version with pyenv global 2.7.18 Add eval "$(pyenv init --path)" to ~/.zprofile (or ~/.bash_profile or ~/.zshrc, whichever you need) Relaunch the shell .. 더보기
App Store Connect API 준비 Issuer ID, KEY ID 생성 및 .p8 파일 다운 App Store Connect -> Users and Access -> Keys -> App Store Connect API JWT(JSON Web Token) 방식으로 Bearer Token 생성 https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests 1. jwt 설치 gem install jwt --user-install 2. jwt.rb 파일 생성 및 토큰 발행 require "base64" require "jwt" ISSUER_ID = [YOUR_ISSUER_ID] KEY_ID = [YOUR_KEY_ID] exp = .. 더보기
swift-format 에러발생 에러메시지 : error: Unable to format ... The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax 원인 및 해결방법 1. swift-format 버전이 설치된 xcode의 Swift 버전과 호환되지 않는경우 - 해결방법 swift-format 및 xcode 버전 확인 후 swift-format을 적절한 버전으로 업그레이드 하거나 xcode를 적절한 버전으로 다운그레이드 https://github.com/apple/swift-format 2. xcode 파일 경로를 못찾는 경우 - 해결방법 1) xcode의 이름을 xco.. 더보기
cocoapods 설치 안되거나 pod 명령어를 찾을 수 없을 때 gem 찾을수 없다고 할때 "You don't have [PATH ]in your PATH, gem executables will not run." while using "gem install --user-install bundler" export GEM_HOME="$(ruby -e 'puts Gem.user_dir')" export PATH="$PATH:$GEM_HOME/bin" https://stackoverflow.com/a/68139636 export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH gem install cocoapods --user-install https://stackoverflow.com/a/14204067 더보기
swift와 objc에서 순환참조 처리하기 순환참조는 메모리누수를 발생시킬 수 있다. 따라서 weak reference를 통해 순환참조를 피할 수 있다. 예시 Swift func retainCycleHandler() { someObject.someBlock { [weak self] in guard let self = self else { return } self.navigationController?.popViewController(animated: true) } } objc - (void)retainCycleHander { __weak __typeof(self)weakSelf = self; [someObject someBlock:^ { __strong __typeof(weakSelf)self = weakSelf; if (!self) { retu.. 더보기
objc에서 swift 파일 임포트 동일 프로젝트인 경우 불러오기 - objc 파일에서 불러오기 #import "ProductName/ProductName-Swift.h" - swift 파일에서 불러오기 import ProductName 다른 프로젝트인 경우 불러오기 @import ProductName; objc 사용 허용 어노테이션 및 퍼블릭 extension UIImage { @objc public static var someImage: UIImage? } https://stackoverflow.com/a/24102880 더보기
gem install bundler permission issue 이런 에러가 발생할 경우 gem install bundler ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory. 아래 명령어로 설치하면 됨 gem install bundler --user-install https://bundler.io/doc/troubleshooting.html Bundler: The best way to manage a Ruby application's gems Troubleshooting common .. 더보기