#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
/* Here's the main point. Data type: NSString string, nsdate date, Nsarry number
Nsdictionary dictionary. */
#pragma make string
/*
Strings are very common data types, and the string type in OC is: NSString class, similar to char* in C, you can get the length using the Length property
This class provides a rich way for us to use
*/
#pragma make string creation method
NSString *[email protected] "Hello";
NSString *str2=[nsstring STRINGWITHSTRING:STR];
NSString *str3=[[nsstring alloc]initwithstring:@ "Hello"];
NSString *str4=[[nsstring alloc]initwithformat:@ "hello%d", 2];
#pragma make string Merge method
-(nsstring*) stringbyappendingstring: (nsstring*) astring;
-(nsstring*) Stringbyappendingformat: (nsstring*) format ...
#pragma Makr string interception method
-(nsstring*) Substringfromindex: (Nsuinteger) Anindex;
-(nsstring*) Substringtoindex: (Nsuinteger) Anindex;
#pragma make string substitution method
NSString *[email protected] "Helloword";
Nsrange Range=nsmakerange (3, 3);
NSString *str9=[str8 stringbyreplacingcharactersinrange:range withstring:@ "*"];
#pragma make string comparison method
-(BOOL) isequaltostring: (nsstring*) astring;
-(Nscomparisonresult) Compare: (nsstring*) string;
#pragma makensdate Date
/*nsdate is the base class for working with dates and times, and for saving time values, while providing methods to handle some of the seconds-based difference and the sooner or later comparisons between dates.
The class method used to create the NSDate instance
+ (ID) date; The return value is the current date and time.
+ (ID) Datewithtimeintervalsincenow: (nstimeinterval) secs;
Returns the current time as a baseline and then warns of secs seconds.
+ (ID) Datewithtimeinterval: (Nstimeinterval) Tisincedate: (nsdate*) refdate;
Returns the time that is refdate for the specified time, then the ti seconds. */
#pragma make array
/*
Nsarray non-variable group, easy to do find
[Array Count]: the length of the array.
[Array Objectatindex 0]: The ID of the incoming array pin gets the data object.
[Arraywithobjects; ...] : Initializes an assignment to an array object. You can write pointers to arbitrary objects, and you must use nil at the end.
Nsmutablearray variable Object array, deleting add modifications.
[Nsmutablearray Arraywithcapacity:6]: Initializes the length of the variable group object, if the subsequent code continues to add an array longer than the length of 6, the length of the Nsmutablearray is automatically expanded, and 6 is the granularity that you can set.
[Array AddObject: ...] : Adds a data object to the tail of a mutable array.
[Array Addobjectsfromarray:..] : Adds an array object to the tail of a mutable array.
*/
#pragma make dictionary
/*
The dictionary stores data in the form of Key-value.
Object storage in the dictionary is not in order, is not available for subscript access, and key is used to represent each object.
Dictionaries in the Cocoa Framework: Nsdictionary and Nsmutabledictionary.
(1) Creating an immutable dictionary
[Nsdictionary Dictionarywithobjectsandkeys:..] : Creates a Dictionary object directly using the key-value pair, ending with the nil flag.
[Nsdictionary Initwithobjectsandkeys:..] : initializes the Dictionary object with the key-value pair, ending with the nil flag.
[Dictionary count]: Gets the length unit of the dictionary.
[Dictionary Keyenumerator]: stores all keys of the dictionary in Nsenumerator, Nsenumerator is much like an iterator in the Java language, using a quick enumeration to traverse all stored key values in the dictionary.
[Dictionary Objectenumerator]: stores all the value of the dictionary in Nsenumerator, and the usage and the above can be used to traverse the key corresponding to the stored value.
[Dictionary Objectforkey:key]: by passing in the key object can get the current key corresponding to the stored value.
(2) Creating a variable Dictionary object
Nsmutabledictionary is a subclass of Nsdictionary, so it inherits the Nsdictionary method.
[Nsmutabledictionary Dictionarywithcapacity:10]: Create a mutable dictionary initially specifies that its length is 10. Dynamically add data if more than 10 this dictionary length will automatically increase, so do not worry about the array out of bounds. Recommended in this way
[Nsmutabledictionary Initwithcapacity:10]: Just initialize a dictionary with a length of 10.
[Dictionary setobject:@ "Rain Pine Momo" forkey:@ "name"]: Add data dynamically to a mutable dictionary, where the key is name and the value is Rain pine momo. If the data for this key exists in the dictionary, the value of this key is replaced directly. (Easy to mix the place, cautious!) )
[Dictionary removeallobjects ...] : Removes all data from the dictionary.
[Dictionary Removeobjectforkey ...] : Delete the data from the specified key in the dictionary
*/
}
return 0;
}
IOS-OC Data types