출처: http://bitxflow.synology.me/wordpress/?p=311%20

swift: https://indra17.tistory.com/entry/ios-%ED%83%88%EC%98%A5%ED%8F%B0-%EC%B2%B4%ED%81%ACswift

+(BOOL)isJailbroken{
#if !(TARGET_IPHONE_SIMULATOR)
    if ([[NSFileManager defaultManager] fileExistsAtPath:@”/Applications/Cydia.app”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/Library/MobileSubstrate/MobileSubstrate.dylib”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/bin/bash”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/usr/sbin/sshd”]){
        return YES;
    }else if([[NSFileManager defaultManager] fileExistsAtPath:@”/etc/apt”]){
        return YES;
    }
    return NO;

    NSError *error;
    NSString *stringToBeWritten = @"This is a test.";
    [stringToBeWritten writeToFile:@”/private/jailbreak.txt” atomically:YES encoding:NSUTF8StringEncoding error:&error];
    if(error==nil){
        //Device is jailbroken
        return YES;
    } else {
        //Device is not jailbroken
        [[NSFileManager defaultManager] removeItemAtPath:@”/private/jailbreak.txt” error:nil];
    }
    if([[UIApplication sharedApplication] canOpenUrl: [NSURL URLWithString:@”cydia://package/com.example.package”]]){
        //Device is jailbroken
    }
#endif
  
    //All checks have failed. Most probably, the device is not jailbroken
    return NO;
}

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크(swift)  (0) 2020.04.23
swift 타입체크 함수 (UIViewController)  (0) 2019.12.11
xcode에서 개발/운영 환경 설정  (0) 2019.03.28
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13

함수 정의,  UIViewController대신에 원하는 타입의 부모클래스를 넣으면 됨

func isAleadyVC<T>(_ vcs:[UIViewController]?, _ tp: T.Type) -> UIViewController? {
	for i in 0 ..< vcs!.count {
		if (vcs![i] as? UINavigationController) != nil {
			let nc = vcs![i] as! UINavigationController
			if let vc = isAleadyVC(nc.children, tp) {
				return vc
			}
		}
		else if (vcs![i] as? UITabBarController) != nil {
			let tc = vcs![i] as! UITabBarController
			if let vc = isAleadyVC(tc.children, tp) {
				return vc
			}
		}
		else { // always UIViewController
			let vc = vcs![i]
			if type(of: vc) == tp {
				return vc
			}
			if let vc = isAleadyVC(vc.children, tp) {
				return vc
			}
		}
	}
	return nil
}

 

사용

if let homeVC = isAleadyVC(self.window?.rootViewController?.children, HomeVC.self) as? HomeVC {
	...
}

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크(swift)  (0) 2020.04.23
ios 탈옥폰 체크  (0) 2019.12.12
xcode에서 개발/운영 환경 설정  (0) 2019.03.28
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13

페이지 이동 시 도메인을 확인하여 webView.removeJavascriptInterface(SCRIPT_NAME); 을 호출.

 

상황에 따라 handler를 이용하거나 runOnUiThread사용

 

 

----------------------- 추가 --------------------

위의 방법은 HTTPS를 사용하거나, 특정 몇개의 도메인만 사용하는 경우에만 허용됨.

사이트 내부에서 다른 외부 사이트의 이미지들을 로딩하는 경우에는 사용할 수 없는 방법으로, 이 경우에는 prompt를 이용하여 비슷하게 구현가능

1. 서버에서 HTTPS 사용.

 

2-1. 서버에서 HTTPS사용 불가 시 manifest파일의 application태그에 android:usesCleartextTraffic="true" 속성 추가

2-2. 서버에서 HTTPS사용 불가 시 resource/xml폴더에 임의의 xml 파일 생성 후 다음과 같은 내용을 입력 후 manifest파일의 application태그에 android:networkSecurityConfig="@xml/추가한 파일명" 속성추가

<network-security-config>
<domain-config cleartextTrafficPermitted="true">
    <domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
</network-security-config>

 

프로젝트 생성 시 기본적으로 Debug, Release Scheme이 생성되어 있다.

Scheme설정 중 Archive는 Release, Run은 Debug가 기본 설정

 

1. 프로젝트 설정에서 개발, 운영 용 의 설정셋을 추가한다 (Debug설정으로 복사)

 

2. Scheme을 추가한다

 

3. scheme과 설정셋을 매핑

 

4. 개발/운영 설정을 설정셋에 추가한다

프로젝트 설정 - 타겟 - Build Settings - Active Compilation Conditions 의 개발/운영 환경에 macro define값을 추가 (여기선 dev만 구분)

 

5. 소스에서 macro define으로 구분

#if DEV

public static let DOMAIN = "http://개발서버주소"

#else

public static let DOMAIN = "http://운영서버주소"

#endif

 

6. 추가적으로 info.plist파일 복제하여 개발/운영에 따라 앱 이름, bundle ID 등을 변경

'develop > iOS' 카테고리의 다른 글

ios 탈옥폰 체크  (0) 2019.12.12
swift 타입체크 함수 (UIViewController)  (0) 2019.12.11
swift에서 macro define 사용하기  (0) 2019.03.28
swift용 SQLite 클래스  (0) 2018.07.13
ipa 커맨드라인으로 만들기 (xcode 9.2 대응)  (0) 2018.04.09

#ifdefine 은 사용할 수 없다

 

#if, #else, #endif를 사용

1. 프레임 이름

window.frames['frame_name'].location.href = "페이지 주소";

 

2. 프레임 인덱스

window.frames[0].location.href = "페이지 주소";

'develop > javascript' 카테고리의 다른 글

구글 맵이 간헐적으로 표시 되지 않는 현상  (0) 2024.08.15
스크롤 높이 계산  (0) 2018.04.09


Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));



시간을 변경했더라도, 출력할 때 사용하는 SimpleDateFormat을 사용하면 자동으로 Local Time으로 변경된다.

SimpleDateFormat에서도 GMT+0기준으로 변경하기 위해서는 아래와 같은 설정을 해야 한다.


SimpleDateFormat formatter = new SimpleDateFormat(form);

formatter.setTimeZone(TimeZone.getTimeZone("GMT"));


'develop > Java' 카테고리의 다른 글

@Builder로 부모 클래스 멤버 설정  (0) 2025.01.28

CONVERT_TZ(now(), @@session.time_zone, '+00:00')



예전엔 SqliteOpenHelper 상속받아서 썼었는데, 테이블/쿼리 관련해서 간단히 선언만하면 자동으로 구현소스를 만들어 주는게 있다.


나중에 필요할때 써먹어야겠다. (그동안 만들어 놨던 클래스 안녕 ㅠㅠ)


https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#0

+ Recent posts