C++ 2020. 4. 14. 19:09

#include "bigint\BigIntegerLibrary.hh" #include <afx.h> #include <iostream> #include <string.h> #import "winhttp.tlb" no_namespace named_guids char* wc2ansi(CStringW& unicodestr) { char *ansistr; int lenW = wcslen(unicodestr.GetString()); int lenA = WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, 0, 0, NULL, NULL); if (lenA > 0) { ansistr = new char[lenA + 1]; WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, ansistr, lenA, NULL, NULL); ansistr[lenA] = 0; } return ansistr; } VOID ansi2wc(char* ansistr, CStringW& Result) { int lenA = lstrlenA(ansistr); int lenW; BSTR unicodestr; lenW = ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, 0, 0); if (lenW > 0) { // Check whether conversion was successful unicodestr = ::SysAllocStringLen(0, lenW); ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, unicodestr, lenW); } Result = CStringW(unicodestr); return; } VOID SplitKey(CStringW& szSource, CStringW* KeyArr) { DWORD dwPos = 0, dwNextPos = 0, i = 0; dwNextPos = szSource.Find(L",", 0); // Mid의 시작 지점은 0임 do { KeyArr[i++].SetString(szSource.Mid(dwPos, dwNextPos - dwPos)); dwPos = dwNextPos + 1; dwNextPos = szSource.Find(L",", dwPos); }while(dwNextPos != -1); KeyArr[i].SetString(szSource.Mid(dwPos)); return; } PBYTE pkcs1pad2(CStringW& OrgText, int dwPadNum) { PBYTE Buffer = (PBYTE)malloc(dwPadNum); int padIndex = OrgText.GetLength() - 1; while( padIndex >= 0 ) Buffer[--dwPadNum] = ((PBYTE)OrgText.Mid(padIndex--, 1).GetString())[0]; Buffer[--dwPadNum] = 0; while( dwPadNum > 2) Buffer[--dwPadNum] = rand() % 256 + 1; Buffer[--dwPadNum] = 2; Buffer[--dwPadNum] = 0; return Buffer; } VOID Get16Times(BigInteger& Result, DWORD dwTimes) { Result = BigInteger(1); for(int i = 0; i < dwTimes; i++) { Result = Result * BigInteger(16); } return; } VOID RSAFastEncrypt(BigInteger& orgInt, BigInteger& exp, BigInteger& moduler, BigInteger& Result) { Result = orgInt % moduler; for(int i = 0; i < 16; i++) Result = Result * Result % moduler; Result = Result * orgInt % moduler; } int main() { CStringW szID(L"비밀번호"); CStringW szPW(L"아이디"); HRESULT hr = CoInitialize(0); if(SUCCEEDED(hr)){ IWinHttpRequestPtr IE; IE.CreateInstance(CLSID_WinHttpRequest); IE->Open(_bstr_t(L"GET"), _bstr_t(L"http://nid.naver.com/login/ext/keys.nhn")); IE->Send(); CStringW Buffer((wchar_t*)(IE->ResponseText)); CStringW KeyArr[4]; // 먼저 키를 나눈다 SplitKey(Buffer, KeyArr); // Original Text를 형성한다. CStringW OrgText; OrgText = OrgText + (char)KeyArr[0].GetLength(); OrgText = OrgText + KeyArr[0]; OrgText = OrgText + (char)szID.GetLength(); OrgText = OrgText + szID; OrgText = OrgText + (char)szPW.GetLength(); OrgText = OrgText + szPW; // 문자열을 Byte Array로 변환하고 PBYTE TextByteArr = (PBYTE)pkcs1pad2(OrgText, 128); BigInteger orgInt(0); BigInteger bigTimes; // Byte Array를 BigInteger로 치환한다. for(int i = 127; i >= 0; i--) { Get16Times(bigTimes, (127 - i) * 2); orgInt = orgInt + BigInteger(TextByteArr[i]) * bigTimes; } BigInteger Result(0); BigInteger eValue = stringToBigInteger(wc2ansi(KeyArr[2])); BigInteger nValue = stringToBigInteger(wc2ansi(KeyArr[3])); // 암호화를 진행한다. RSAFastEncrypt(orgInt, nValue, eValue, Result); // 이제 로그인을 진행하자 CStringW HeaderString, Converted; ansi2wc((char*)(bigUnsignedToString(Result.getMagnitude()).c_str()), Converted); HeaderString = HeaderString + "enctp=1"; HeaderString = HeaderString + "&encpw=" + Converted.MakeLower(); HeaderString = HeaderString + "&encnm=" + KeyArr[1]; HeaderString = HeaderString + "&svctype=0"; HeaderString = HeaderString + "&id="; HeaderString = HeaderString + "&pw="; HeaderString = HeaderString + "&x=35"; HeaderString = HeaderString + "&y=14"; IE->Open((_bstr_t)L"POST", (_bstr_t)L"https://nid.naver.com/nidlogin.login"); IE->SetRequestHeader((_bstr_t)L"Referer", (_bstr_t)L"http://static.nid.naver.com/login.nhn?svc=wme&url=http%3A%2F%2Fwww.naver.com&t=20120425"); IE->SetRequestHeader((_bstr_t)L"Content-Type", (_bstr_t)L"application/x-www-form-urlencoded"); IE->Send((_bstr_t)HeaderString); CStringW strResponse = (wchar_t*)IE->GetResponseText(); if( strResponse.Find(L"location.replace") != -1 ) std::cout << "로그인에 성공하였습니다." << std:

'C++' 카테고리의 다른 글

[C++] 로그인 프로그램 소스  (0) 2020.04.15
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:07

[PHP]함수의 인수

함수 안에서 사용하는 값을 함수 밖에서 전달할 수 있는데 이 값을 인수라고 한다.

-예

<?php

function check($age) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check(19);

?>

-결과

​프로그래밍

 

인수가 지정되지 않은 경우(에러가 발생한다.)

- 예

<?php

function check($age) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check();

?>

- 결과(에러 발생)

Fatal error: Uncaught ArgumentCountError: Too fewargumenC:/ xampp/hydocs/for:php:

2 Stack trace: #0 C:xampp/hidocs/for

인수에 값이 없는 경우 에러가 발생하므로 인수의 기본값을 사용한다.

-예

<?php

function check($age=19) {

$result = (20 <= $age)?"프로":"그래밍";

print $result."입니다.";

}

check();

?>

 

- 결과(에러가 발생하지 않았다.)

프로그래밍

 

<?php

function test($x1, $x2)(

echo '*'.$x1.$x2.'*';

)

test('핵','커');

?>

결과는 *핵커*

'PHP' 카테고리의 다른 글

[PHP] PHP 문자 N 문자를 연결해보자!  (0) 2020.04.14
[PHP] PHP 함수 생성 및 호출  (0) 2020.04.14
[PHP] PHP 다운로드  (0) 2020.04.14
[PHP] 시작,종류,태그,변수,저장확정자  (0) 2020.04.11
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:05

[PHP]문자와 문자를 연결하기

php에서는 문자와 문자를 연결시 + 대신에 .를 사용한다.

-입력

<?php

echo "*"."아이유";​

?>

-출력

아이유

 

html을 포함한 경우

-줄바꿈이 가능하다.

-입력

​<?php

echo "*"."아이"."</br>"."유2";

?>

-출력

결과

아이유

입력1

<?

$test = "너 ";

$test.= "랑";

$test.= "나";

print $test;

?>

결과

너 랑 나

'PHP' 카테고리의 다른 글

[PHP] PHP 함수의 인수 배우보자!!!  (0) 2020.04.14
[PHP] PHP 함수 생성 및 호출  (0) 2020.04.14
[PHP] PHP 다운로드  (0) 2020.04.14
[PHP] 시작,종류,태그,변수,저장확정자  (0) 2020.04.11
posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:03

[PHP]함수 생성 및 호출

다음은 모두 같은 의미이다.

- 작은 프로그램의 모음

- 서브루틴

- 사용자 정의 함수

사용자 정의 함수를 사용하면 같은 내용을 여러 번 사용할 때 간단히 함수를 불러오면 되서 편리하다.

정의

- function 함수명() {

​ 처리 내용;

}

사용

- 함수명();

* 함수의 정의와 함수의 사용 순서는 상관없다.

​예

<?php

function copyright() {

print "<font size=7>";

print "copyright all right reserved";

print "</font>";

}

copyright();

?>

<?php

fuction test()(

echo 1;

)

test();

?>

함수 실행 예1

<?php

test($x)(

echo $x;

)

test('hello world');

?>

함수 실행 예2

<?php

test($x)(

echo $x;

)

test('hello world');

test('hello jeju');

?>

함수 실행 예3

<?php

test($x)(

echo $x;

)

test('hello');

test('mr my);

test('yesterday);

?>

posted by 핵커 커뮤니티
:
PHP 2020. 4. 14. 19:01
 

PHP For Windows: Binaries and sources Releases

PHP 7.3 (7.3.16) Download source code [27.04MB] Download tests package (phpt) [14.25MB] VC15 x64 Non Thread Safe (2020-Mar-17 15:56:44) Zip [24.43MB] sha256: 61d9c8a85b8cfc84cd72ec754b9fa260c252fafdc7f82c9b835a9ec45353ab62 Debug Pack [23.08MB] sha256: f511

windows.php.net

 

 

posted by 핵커 커뮤니티
:
Olly_Dbg 2020. 4. 14. 18:55
 

OllyDbg v1.10

 

www.ollydbg.de

 

'Olly_Dbg' 카테고리의 다른 글

[올리디버거] 단축키 알아보자  (0) 2020.04.10
posted by 핵커 커뮤니티
:
Ruby 2020. 4. 14. 18:54

https://rubyinstaller.org/downloads/

posted by 핵커 커뮤니티
:
Objective_C 2020. 4. 14. 18:52

9.파운데이션 프레임워크

9-1.루트 클래스

NSObject는 Objective-C의 클래스가 가져야 할 가장 기본적인 기능(메모리 관리, 객체 식별 등)을 제공하며,모든 클래스는 NSObject를 직접 혹은 간접적으로 상속함으로써 그 기능들을 사용할 수 있게된다. 사용자가 직접 구현하는 클래스도 이를 위해 NSObject를 상속하는 것을 절대 잊지말아야한다.

 

9-2.문자열 관련 클래스

9-2-1.NSString

유니코드 방식으로 문자열을 다루는 기능을 제공하는 클래스,. 파운데이션 프레임워크에서 가장 많이 사용되는 클래스

-기본사용방법 : 문자열 앞에 항상 '@'를 붙여주어야한다. NSString *string = @"string test";

-포맷표현 방식 : 다른언어의 %s가 아니라 %@사용한다. 나머지 타입은 같다(%d,%f,%u)

NSString *string1 = [[NSString alloc]initWithFormat:@"%@",@"string"];

NSStirng *string2 =[NSString stringWithString:@"string"];

-생성 메소드 : 클래스 메소드는 alloc 또는 copy로 시작하는 이름을 갖지 않으므로 사용이 끝난 후 release할 필요없다.

인스턴스 메소드들은 alloc 메소드를 이용하여 생성되므로, 사용이 끝난 후에는 반드시 release를 호출해야한다.

//빈 문자열을 가지는 객체를 생성하여 반환

+(id)string

//주어진 문자열을 가지는 객체를 생성하여 반환

+(id)stringWithFormat:(NSString *)format, …

+(id)stringWithString:(NSString *)aString;

//위 메소드들의 인스턴스 메소드 형태, 기능은 동일

-(id)initWithFormat:(NSString *)format …

-(id)initWithString:(NSString *)aString

//사용예

NSString *string1 = [NSString string];

NSString *string2 = [NSString stringWithFormat:@"String: %@", @"Test"];

NSString *string3 = [NSString stringWithString:@"String"];

NSString *string4 = [[NSString alloc] initWithFormat:@"String : %@",@"Test"];

NSString *string5 = [[NSString alloc] initWithString:@"String"];

-결합메소드

//현재 문자열과 주어진 문자열을 결합하여 반환

-(NSString *)stringByAppendingFormat:(NSSting *)format …

-(NSString *)stringByAppendingString:(NSString *)aString

//사용예

NSString *string1 = @"Hello"

NSString *string2 = [stirng1 stringByAppendingFormat:@"%@",@"World"];

NSString *string3 = [stirng1 stringByAppendingString:@" World"];

-분리 메소드

//현재 문자열을 검사하여 주어진 문자열이 나타낼 때마다 문자열 분리

-(NSArray *)componentsSeparatedByString:(NSString *)separator

//현재 문자열의 주어진 위치 이후 문자열 반환

-(NSString *)substringFromIndex:(NSUInteger)anIndex

//현재 문자열의 주어진 위치까지의 문자열 반환

-(NSString *)substringToIndex:(NSUInteger)anIndex

 

//사용예

NSString *string1 = @"String1, String2, String3";

NSArray *iterms =[string1 componentsSeparatedByString:@". "];

//ite는 :{@"String1", @"String2", @"String2"}

NSString *string2 =@"String";

NSString *string3 =[string2 substringFromIndex:3];

NSString *string4 =[string2 substringToIndex:3];

//string 2: @"ing" string 4:@"str"

-값 변환 메소드

//현재 문자열에 해당하는 정수값 반환

-(int)intValue

//현재 문자열에 해당하는 실수값 반환

-(float)floatValue

-(double)doubleValue

//사용예

NSString *string1 =@"5";

int intValue =[string1 intValue]; //intValue : 5

NSString *string2 =@"2.34";

float floatValue = [string2 floatValue]; //2.34

double double Value = [string2 doubleValue]; //2.34

-비교 메소드

//현재 문자열이 주어진 문자열로 시작하는지 검사

-(BOOL)hasPrefix:(NSString *)aString

//현재 문자열이 주어진 문자열로 끝나는지 검사

-(BOOL)hasSuffix:(NSString *)aString

//현재의 문자열이 주어진 문자열과 동일하지 검사

-(BOOL)isEqualToString:(NSString *)aString

//사용예

NSString *string1 = @"Hello World!";

BOOL value1 = [string1 hasPrefix:@"Hel"];

BOOL value2 = [string1 hasSuffix:@"orld"]; //value1,value2 :YES

BOOL value3 = [string1 isEaualToString:@"Hello World!"]; //value3 :YES

-기타 메소드

//문자열의 길이를 반환

-(NSUInteger)length

//문자열읮 ㅜ어진 위치에 해당하는 문자를 반환

-(unichar)characterAtIndexLNSUInteger)index

//사용예

NSString *string = @"String";

int length = [string length]; //length :6

unichar value = [string characterAtIndex:3]; //value : i

9-2-2.NSMutableString

NSString 클래스를 상속하는 자식 클래스, 문자열을 한번 할당하면 변경할 수 없는 NSString과는 달리 수정할 수 있다는 것이 장점, 참고로 파운데이션 프레임워크 클래스 중에서 이름에 Nutable이 포함된 클래스 (NSMutableArray, NSMutableDictionary 등)는 값을 수정할 수 있는 클래스다,.

 

//주어진 문자열을 현재의 문자열과 결합

-(void)appendFormat:(NSString *)format ..

-(void)appendFormat:(NSString *)aString

//주어진 문자열을 현재 문자열의 주어진 위치에 사입

-(void)insertString:(NSString *)aString atIndex:(NSUInteger)anIndex;

//현재의 문자열을 주어진 문자열로 대체

-(void)setString:(NSString *)aString

//사용예

NSMutableString *string. = [NSmutableString stringWithString:@"Hello"]; //String :@"Hello"

[string appendFormat:@"%@",@"Wor"]; //String :@"Hellowor"

[string appendString:@"ld!"] //string: @"Helloworld!"

[string insertString:@" " atIndex:5]; //string: @"Hello world!"

[string setString:@"Bye World!"]; //string: @"Bye World!"

 

9-3.객체 집합 관련 클래스

NSArray : 순서가 있는 객체 리스트를 관리

NSDictionary : 키 – 값 형태의 객체 리스트를 관리

NSSet : 순서가 없는 객체 리스트를 관리

위는 할당된 내용을 수정할 수 없는 클래스지만. 이들 클래스 이름에 Mutable이 들어간 MSMutableArray, NSMutableDictionary, NSMutableSet는 수정할수 있는 클래스이다.

 

9-3-1.NSArray

-생성메소드

//사용예

NSDate     *aDate = [NSDate distantFuture];

NSValue     *aValue = [NSNumber numberWithInt:5];

NSString     *aString = @"a string";

// +(id)arrayWithObjects : 주어진 객체들을 포함하는 객체를 생성하여 반환

NSArray *array1 = [NSArray arrayWithObjects:aData, avalue, aString, nil]; //마지막은 반드시 nil을 전달

// -(id)initWithObjects : arrayWithObjects의 인스턴스 메소드 형태, 기능은 동일

NSArray *array2 = [[NSArray alloc]initWithObjects:aData, aValue, aString, nil]; //마지막은 반드시 nil을 전달

//+(id)arrayWithArray: 주어진 배열 내의 인자들을 포함하는 객체를 생성하여 반환

NSArray *array3 = [NSArray arrayWithArray: array1];

//-(id) initWithArray : +arrayWithArray의 인스턴스 메소드 형태 기능은 동일

NSArray *array4 = [[NSArray alloc] initWithArray: array1];

주요메소드

NSString *item1 = @"1", *item2 = @"2", *item3=@"3";

NSArray *array = [NSArray arrayWithObjects: item1, item2, item3, nil]; //array :{item1, item2, item3}

//주어진 배열 내의 인자의 수를 반환

int cout : [array count]; //count :3

//주어진 인덱스의 객체를 반환

NSString *string = [array objectAtIndex:1]; //string :@"2"

//주어진 객체의 배열 내의 인덱스를 반환

NSUInteger index = [array indexOfbject :item3]; //index:2

 

9-3-2.NSMutabelArray

NSString *item1 = @"1", *item2 = @"2", *item3=@"3", *item4=@"4";

NSMutableArray *array =[NSMutableArray arrayWithObjects: item1, item2, item3, nil]; //array :{item1, item2, item3}

//주어진 인자를 지정된 위치에 삽입한다.

[array insertObject:item4 atIndex:2]; ////array :{item1, item2,item4, item3}

//지정된 위치의 인자를 삭제한다.

[array removeObjectAtIndex:3]; ////array :{item1, item2,item4}

//주어진 인자를 배열 끝에 추가한다.

[array addObject:item3]; // array :{item1, item2,item4,item3}

//마지막 인자를 삭제한다.

[array removeLastObject]; // array :{item1, item2,item4}

//현재 배열의 지정된 위치의 객체를 주어진 객체로 대체한다.

[array replaceObjectAtIndex:2, withObject:item3]; // array :{item1, item2,item3}

 

9-3-3.NSDictionary –stl의 map

-생성메소드

//+(id) dictionaryWithObjectsAndKeys: 주어진 객체, 키 값으로부터 객체를 생성반환

NSDictionary *dict1 = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2",nil];

//-(id) initWithdictionaryWithObjectsAndKeys:+(id) dictionaryWithObjectsAndKeys의 인스턴스 메소드 형태

NSDictionary *dict2 = [[NSDictionary alloc] initWithdictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2",nil];

-주요메소드

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"Chris", @"name", @"programmer", @"job",nil]; //dirct :{@"job" : @"programmer", @"name :@"Chris"}

//dictionary에 있는 객체의 수를 반환

NSUInteger count = [dict count]; //count :2;

//dictionary에 있는 모든 키 값들을 반환

NSArray *keys= [dict allKeys]; //Keys:{@"job",@"name"};

//dictionary에 있는 모든 객체들을 반환

NSArray *values = [dict allValues]; values :{@"programmer",@"Chris"}

//주어진 키 값을 갖는 객체를 반환

NSString *string = [dict objectForKey:@"name"]; //string : @"Chris"

9-3-4.NSMutableDictionary

NSMutableDictionary *dict =[NSMutableDictionary dictionary]; //Dict: { }

//주어진 객체와 키 조합을 추가한다.

[dict setObject:@"Chris" forKey:@"name"]; //dict:{@name: @"chris"}

[dict setObject:@"programmer" forKey:@"job"]; //dict: {@"job": @"programmer", @"name" : @"Chris"}

//주어진 객체와 키 조합을 삭제

[dict removeObjectForKey:@"name"]; //dict : {@"job" : "programmer"};

//모든 객체-키 조합 삭제

[dict removeAllObjects];//dict:{ }

9-3-5.NSSet –NSArray와 달리 순서가 없다.

-생성메소드

NSDate *aDate = [NSDate distantFuture];

NSValue *aValue = [NSNumber numberWithInt:5];

NSString *aString = @"a string";

//주어진 객체들을 포함하는 객체를 생성하여 반환

NSSet "mySet =[NSSet setWithObjects:aDate, aValue, aString, nil];

// NSSet "mySet =[[NSSet alloc]initWithObjects:aDate, aValue, aString, nil];

-주요메소드

NSDate *aDate = [NSDate distantFuture];

NSValue *aValue = [NSNumber numberWithInt:5];

NSString *name = @"Chris";

NSSet *mySet =[NSSet setWithObjects: date, value, name, nil]; //mySet :{value, name, date}

//NSSet 에 들어있는 오브젝트 객체 개수

NSUInteger count =[mySet count]; //count :3

//NSSet에 들어있는 모든 오브젝트 객체 반환

NSArray *array1 = [mySet allObjects]; // array1 : {value, name, date;

//NSSet 내에 주어진 객체가 존재하는지 검사하여 결과 반환

BOOL result = [mySet containsObject:@"Chris"]; //result :YES

9-3-6 NSMutableSet

NSDate *aDate = [NSDate distantFuture];

NSValue *aValue = [NSNumber numberWithInt:5];

NSString *name = @"Chris", *job = @"programmer";

NSMutableSet *mySet =[NSMutableSet setWithObjects: date, value, name, nil]; //mySet :{value, name, date}

//set에 주어진 객체를 추가

[mySet addObject:job]; //mySet :{job, value, name, date}

//set에 주어진 객체 삭제

[mySet removeObject:@"Chris"]; //mySet :{job, date,value}

//set의 모든 객체 삭제

[mySet removeAllObjects]; //mySet: {}

9-3-7 객체 탐색

-객체를 탐색하는 예

NSArray *array = [NSArray arrayWithObjects:@"One",@"Two", @"Three", @"Four", nil];

NSString *item = nil;

for( item in array){

if([item isEqualToString:@"Three"]){

break;

}

}

-NSEnumerator를 사용하는 방법

NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @Three", @"Four", @nil];

NSString *item = nil;

NSEnumerator *enumerator = [array objectEnumerator];

 

while(item = [enumerator nextObject]){

if( [item isEqualToString:@"Three"]){

break;

}

}

NSEnumerator 사용하면 좋은예

NSArray의 경우 reverseEnumerator 메소드를 이용하여 객체를 역순으로 탐색 할수 있다.

objectEnumerator 대신에 reverseEnumerator 메소드를 호출하면 된다.

NSDictionary의 경우 NSEnumerator를 이용하면 키 값뿐 아니라 객체도 탐색할 수 있다. 키 값을 탐색할때는 KeyEnumerator 메소드, 객체 값을 탐색할때는 objectEnumerator를 이용하면 된다

 

9-4. 값(정수 및 실수)표현 관련 클래스

9-4-1.NSNumber

NSValue 클래스를 상속하는 자식 클래스, BOOL, char, int, float와 double 등 각종 값을 설정하고 반환하는 기능을 수행한다.

NSNumber *boolNumber = [NSNumber numberWithBool:YES];

NSNumber *intNumber = [NSNumber numberWithInt:23];

NSNumber *doubleNumber = [NSNumber numberWithDouble:23.46];

BOOL     value1 = [boolNumber boolValue];

int     value2 = [intNumber intValue];

double     value3 = [doubleNumber doubleValue];

//값비교

NSNumber *intNumber = [NSNumber numberWithInt:23];

NSNumber *floatNumber = [NSNumber numberWithFloat:3.45];

NSString *string1 = [intNumber stringValue]; //string1 : 23

if(NSOrderedAscending == [intNumber compare:floatNumber]{

}

BOOL equality = [intNumber isEqualToNumber:floatNumber];

 

//compare:메소드는 kemdarhk 같은 반환값을 가지게된다.

NSOrderedAscending    :현재 값보다 주어진 값이 클경우

NSOrderedDescending    :현재 값보다 주어진 값이 작은경우

NSOrderedSame        :현재 값과 주어진 값이 같은 

'Objective_C' 카테고리의 다른 글

[Objective-C] 기초배우기 (3)  (0) 2020.04.14
[Objective-C] 기초배우기 (2)  (0) 2020.04.14
[Obejective-C] 기초배우기 (1)  (0) 2020.04.13
posted by 핵커 커뮤니티
: