Nsoperation
- Nsoperation is an abstract class and does not have the ability to encapsulate operations, it must use its subclasses
Nsinvocationoperation
- Nsblockoperation
- Custom operation
-
@implementation xmgoperation-(void) main{ NSLog (@ "%s,%@", __FUNC_ _,[nsthread CurrentThread]);} @end
- Nsoperationqueue
GCD Queue and Nsoperationqueue comparison
- GCD
- Serial: Create yourself, Home row
- Concurrency: Create yourself, Global
Nsoperationqueue
- Create yourself: Alloc/init
- Main queue: Mainqueue
-
Nsoperationqueue features
- own create queue to open a new thread
- Concurrency: maxConcurrentOperationCount-1
- Serial: Maxconcurrentoperationcount = 1
- task added to
mainqueue
does not open new thread in queue
Invocation
- Block
-
//1. Create a queueNsoperationqueue *queue =[[Nsoperationqueue alloc] init]; //2. Packaging TasksNsblockoperation *OP1 = [Nsblockoperation blockoperationwithblock:^{NSLog (@"1 =%@", [Nsthread CurrentThread]); }]; //3. Add a task to the queue[Queue Addoperation:op1]; //1. Create a queueNsoperationqueue *queue =[[Nsoperationqueue alloc] init]; //The Addoperationwithblock method will do two things//1. Create a Nsblockoperation object based on the incoming block//2. Add an internally created Nsblockoperation object to the queue//2. Add a task to the queue[Queue addoperationwithblock:^{NSLog (@"1 =%@", [Nsthread CurrentThread]); }]; [Queue Addoperationwithblock:^{NSLog (@"2 =%@", [Nsthread CurrentThread]); }];
- Custom
- Pause-Resume
- Cancel
- inter-thread communication
- Dependency and monitoring
- Image download
- Directory structure
Documents
-
- You need to save files or data generated by the "application itself", such as: game progress, drawing of graffiti software
- Files in the directory are automatically saved in ICloud
- Note: Do not save files downloaded from the network, otherwise you will not be able to shelves!
-
Caches
- Save temporary files, "need to use later", for example: Cached pictures, offline data (map data)
- The system does not clean up files in the cache directory
- "Must provide a cleanup solution for the cache directory" when the program is being developed
Preferences
- User preferences, use Nsuserdefault Direct Read and write!
- If you want data to be written to disk in a timely manner, you also need to call a synchronization method
Tmp
- Save temporary files, "Follow up no need to use"
- Files in the TMP directory, the system will automatically clean up
- Restart your phone and the TMP directory will be emptied
- System also cleans up automatically when the system is running out of disk space
Encapsulation get File path method
-(NSString *) cachedir{//1. Get the Cache directoryNSString *dir =[Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES) lastobject]; return[dir stringbyappendingpathcomponent:[self lastpathcomponent];}-(NSString *) Documentdir {nsstring*dir =[Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) lastobject]; return[dir stringbyappendingpathcomponent:[self lastpathcomponent];}-(NSString *) TmpDir {nsstring*dir =nstemporarydirectory (); return[dir stringbyappendingpathcomponent:[self lastpathcomponent];}
-
- Sdwebimage Architecture
Sdwebimagemanager
- Sdimagecache
- Sdwebimagedownloader
- Sdwebimagedownloaderoperation
Sdwebimage Common face questions
What is the default cache time?
The cached address
- NSString *fullnamespace = [@ "Com.hackemist.SDWebImageCache." Stringbyappendingstring:ns];
Cleandisk How to clean up outdated images
- Delete files older than the expiration date
- Save file properties to calculate disk cache footprint
- If the remaining disk cache space exceeds the maximum limit, perform a cleanup operation again, deleting the oldest file
Cleardisk How to clean up a disk
- Delete Cache Directory
- New Cache Directory
Sdwebimage How to play a picture
- Remove each frame in the GIF to create an animated picture
Sdwebimage How to determine the type of picture
- Determine the first 8 bytes of a picture binary
- Kpngsignaturebytes[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
-
Cocoapods installation
- update gem
- Update R Uby software source
- gem sources--remove https://rubygems.org/
- gem Sources-a http://ruby.ta obao.org/
- gem sources-l
- install cocoapods
- sudo gem install cocoapods
- replace mirror index of cocoapods
- pod repo remove master
- pod repo add master&nb Sp;http://git.oschina.net/akuandev/specs.git
- pod repo add master https://gitcafe.com/akuandev/ Specs.git
- pod repo update
- set pod warehouse
- test
-
Uninstall cocoapods
- sudo g EM uninstall cocoapods
-
Cocoapods use:
- use to create a new file named Podfile
- will depend on the name of the library The second column is in the file
platform :iospod‘AFNetworking‘
- Comment Items
- 1. After using Cocopods to manage the library, open the project later with Xxxx.xcworkspace instead of the previous. xcodeproj file
- 2. Each time you change the Podfile file, you need to re-execute the pod update command.
- 3.CocoaPods when performing pod install and pod Update, the Cocopods Spec warehouse index is updated first. Use the--no-repo-update parameter to disable index update operations
pod install --no-repo-updatepod update --no-repo-update
IOS Multithreading and other additions 02