I stumbled across the following and can't seem to work out why this works. Please can you explain why I don't need to use a pointer before range
?
NSString *d = @"The quick brown fox";
NSRange range = [d rangeOfString:@"brown"];
A pointer is a variable that stores the address of another variable. Unlike other variables that hold values of a certain type, pointer holds the address of a variable. For example, an integer variable holds (or you can say stores) an integer value, however an integer pointer holds the address of a integer variable.
There are majorly four types of pointers, they are: Null Pointer. Void Pointer. Wild Pointer. Dangling Pointer.
The Pointer in C, is a variable that stores address of another variable. A pointer can also be used to refer to another pointer function. A pointer can be incremented/decremented, i.e., to point to the next/ previous memory location. The purpose of pointer is to save memory space and achieve faster execution time.
Definition of pointer 1a Pointers plural : the two stars in the Big Dipper a line through which points to the North Star. b : one that points out especially : a rod used to direct attention. c : a computer memory address that contains another address (as of desired data)
NSString
is an object type. All object types are pointers and can't be created on the stack. NSRange
is a C-struct. Structs can be created on the stack, and thus aren't necessarily all pointers.
There isn't a good guide to know which ones are objects, and which are structs. You'll just have to check for each type as you move forward.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With