Static NSMutableDictionary

I want to use a static NSMutableDictionary. Can you help how to use static NSMutableDictionary in a class.

Is it correct? .h file

+(NSMutableDictionary*)contactsToAssignBill; +(void)setContactsToAssignBill:(NSMutableDictionary*)value; 

.m file

 static NSMutableDictionary * contactsToAssignBill; +(NSMutableDictionary*)contactsToAssignBill { if (!contactsToAssignBill) contactsToAssignBill = [[NSMutableDictionary alloc] init]; return contactsToAssignBill; } +(void)setContactsToAssignBill:(NSMutableDictionary *)value { if(contactsToAssignBill != value) { [contactsToAssignBill release]; contactsToAssignBill = [value mutableCopy]; } } 
+6
source share
1 answer

This is the right way to do this. Just keep in mind that the dictionary will not be released at any time.

+2
source

Source: https://habr.com/ru/post/919673/


All Articles