The description method is an instance method of NSObject, and all classes that inherit the NSObject base class have that method. Used to "Describe the ego", when the method is executed, the system outputs self-describing information about the object. The description method provided by the NSObject class always returns the < class name: 16, if a more detailed description of the class is required, you need to define the description method yourself.
O-c determine whether two variables are equal by two methods: 1, using the = = operator 2, using the IsEqual method//
//MAIN.M
//IsEqual
//
//Created by Mac on 14-11-28.
//Copyright (c)yearsmac. All rights reserved.
//
#import<Foundation/Foundation.h>
intMain (intargc,Const Char* argv[]) {
@autoreleasepool{
//Insert code here ...
NSLog (@ "Hello, world!");
intit = $;
floatFL =65.0f;
// the output1represent True
NSLog (@ "and the65.0fAre they equal? :%d " , (it = = FL));
Charch =' A ';
//the output1represent True
NSLog (@ "and the' A 'Are they equal? %d ", (it = = ch));
nsstring* str1 = [NSString stringWithFormat:@ "Hello"];
nsstring* str2 = [NSString stringWithFormat:@ "Hello"];
nsstring* STR3 = [NSString stringWithFormat:@ "Hi"];
//the output0represent false
NSLog (@ "Str1and thestr2Are they equal? %d ", (str1 = = str2));
// the output1represent True
NSLog (@ "Str1isisequal str2? %d ", [str1 isequal:str2]);
//becauseNSDatewith theNSStringclass does not have an inheritance relationship,
NSLog (@ "str1 is equal str3?%i", [str1 ISEQUAL:STR3]);
}
return0;}
==>>
2014-11-28 19:12:29.006 isequal[2359:303] Hello, world!
2014-11-28 19:12:29.007 isequal[2359:303]
and the
65.0f
Are they equal?
: 1
2014-11-28 19:12:29.008 isequal[2359:303]
and the
' A '
Are they equal?
1
2014-11-28 19:12:29.010 isequal[2359:303] str1
and the
str2
Are they equal?
0
2014-11-28 19:12:29.010 isequal[2359:303] str1
is
isequal str2
?
1
2014-11-28 19:12:29.011 isequal[2359:303] str1 is equal STR3? 0 Program ended with exit code:0
"Object-c" Processing object: Description method, IsEqual method