1
에서 비교 CFBundleVersion는
NSString *appBundleID [email protected]"net.someapp.app";
NSString *[email protected]"net.someapp.app2";
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:
@"/var/mobile/Library/Caches/com.apple.mobile.installation.plist"];
NSDictionary *User = [dict valueForKey:@"User"];
//get first app version
NSDictionary *bundleID = [User valueForKey:appBundleID];
NSString *appVersion = [bundleID valueForKey:@"CFBundleVersion"];
//get second app version
NSDictionary *bundleID2 = [User valueForKey:appBundleID2];
NSString *appVer2 = [bundleID2 valueForKey:@"CFBundleVersion"];
[dict release];
if ([appVersion isEqualToString:appVer2]) {
NSString *str1=[NSString stringWithFormat:@"Original Version: %@",appVersion];
NSString *str2=[NSString stringWithFormat:@"2nd Version: %@",appVer2];
NSString *msg=[NSString stringWithFormat:@"%@\n%@",str1,str2];
UIAlertView* alertView = [[UIAlertView alloc]
initWithTitle:@"Same Versions!" message:msg delegate:nil
cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
else {
NSString *str1=[NSString stringWithFormat:@"Original Version: %@",appVersion];
NSString *str2=[NSString stringWithFormat:@"2nd Version: %@",appVer2];
NSString *msg=[NSString stringWithFormat:@"%@\n%@",str1,str2];
UIAlertView* alertView = [[UIAlertView alloc]
initWithTitle:@"Different Versions!" message:msg delegate:nil
cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
의 버전 아이폰
에 설치된 모든 응용 프로그램의 정보를 포함하는 com.apple.mobile.installation.plist 안에이 개 앱의CFBundleVersion
키를 비교하기 위해 노력하고있어
내가 수동으로있는 NSString을 설정 한 경우 :
두 애플리케이션은 현재 2.11.8 나는 다음과 같은 잘못된 결과를 얻고있다로 설정
NSString *appVersion [email protected]"2.11.8";
NSString *appVer2 [email protected]"2.11.8";
내가 올바른 원하는 결과를 얻을 : 나는 또한 문자열을 비교하는 다른 방법을 시도하지만 결과는 항상 동일
를, 그래서 문제가의 값을 가져 오는으로 추측 열쇠? 도움이 필요합니다
'NSLog (@ "> % @<", appVersion)'및'NSLog (@ "> % @<", appVer2)'의 출력을 표시 할 수 있습니까? –
안녕하세요, NSLog (@ "Same Versions!"), /'NSLog (@ "다른 버전!"), "NSLog (@"> % @< ", appVersion); NSLog (@ "> % @<", appVer2); 그리고이 미친 결과를 확인하십시오 https://ghostbin.com/paste/gfwax 마지막 숫자가 임의의 것들을 보여주고 있습니다 !!! – Chta7
문자열을 비교하고 경고를 생성 한 후 사전을 해제하면 어떻게됩니까? –