-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGlobalVariables.m
62 lines (48 loc) · 1.29 KB
/
GlobalVariables.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// GlobalVariables.m
// projectoListaClientes
//
// Created by Tiago Sousa on 15/05/2011.
// Copyright 2011 ArquiConsult. All rights reserved.
//
#import "GlobalVariables.h"
//Source: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32
@implementation GlobalVariables
@synthesize coreDataManager;
static GlobalVariables *sharedGlobalVariables = nil; //Está aqui guardada a instancia estática (e unica) da minha class
+ (GlobalVariables *) sharedInstance
{
//Se nao existir uma instancia, cria uma
if (sharedGlobalVariables == nil) {
sharedGlobalVariables = [[super allocWithZone:NULL] init];
}
//Retorna a instancia desta classe
return sharedGlobalVariables;
}
//Override a estes métodos impede que se crie outras instancias deste objecto
//E se trate da parte da gestao de memória como deve ser feito
+ (id)allocWithZone:(NSZone *)zone
{
return [[self sharedInstance] retain];
}
- (id)copyWithZone:(NSZone *)zone
{
return self;
}
- (id)retain
{
return self;
}
- (NSUInteger)retainCount
{
return NSUIntegerMax; //denotes an object that cannot be released
}
- (void)release
{
//do nothing
}
- (id)autorelease
{
return self;
}
@end