Bonsoir à tous !

Je viens vers vous car j'ai un soucis avec mon code Objective C (Comme vous pouvez vous en douter :p )

Donc d'abord mon projet, je vais le résumer sinon ça sera trop compliqué.
Le principal but est qu'on lance l'application sur deux devices (Ipad ou Iphone). Le premier utilisateur dessine un mot et l'envoie au deuxième utilisateur qui doit deviner le mot à l'aide du dessin.

Alors voilà, après de multipli recherche, travail ... j'ai une version à peu près fonctionnelle. Mais je viens de me rendre compte que j'ai un problème de mémoire
En fait, quand l'utilisateur dessine, au bout d'un moment, le device qui est censé recevoir le dessin plante. Ce que je peux comprendre, parce que le dessin ne se charge que à la fin, une fois que l'utilisateur 1 a cliqué sur "Envoyer".

Je vous met le code :
"Côté Serveur, donc Utilisateur 1, celui qui dessine" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	if (nbJoueur == 0 ) {
		UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Aucun joueur" message:@"Vous n'avez pas rajouté de joueur" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[servicesDisabledAlert show];
	}
	else if (!thread_fini) {
		UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:@"Joueur en attente" message:@"Un joueur est en attente de connection. Vous ne pouvez pas dessiner pendant ce temps là." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[servicesDisabledAlert show];
	}
	else {
		mouseSwiped = NO;
		UITouch *touch = [touches anyObject];
 
		lastPoint = [touch locationInView:self.view];
		if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
			lastPoint.y -= 90;
		}
		else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
			lastPoint.y -= 200;
		}
		else {
			perror("Erreur d'appareil");
		}
		strcpy(type, "Began\0");
		strcpy(taille, "\0");
		strcpy(couleurChar, "\0");
		convChar = [NSString stringWithFormat:@"%f\0", lastPoint.x];
		strcpy(pointX,[convChar UTF8String]);
		convChar = [NSString stringWithFormat:@"%f\0", lastPoint.y];
		strcpy(pointY,[convChar UTF8String]);
		envoiPoint();
		nbThreadDessin++;
	}
}
 
void envoiPoint () {
	int sock_err = 0;
 
	sock_err = send(csockDessin, pointX, 5, 0);
	if (sock_err != SOCKET_ERROR) {
		printf("Chaine envoyée : Point X : %s\n",pointX);
	}
	else
		perror("Erreur : Point X");
 
	sock_err = send(csockDessin, pointY, 5, 0);
	if (sock_err != SOCKET_ERROR) {
		printf("Chaine envoyée : Point Y : %s\n",pointY);
	}
	else
		perror("Erreur : Point Y");
 
	sock_err = send(csockDessin, type, 6, 0);
	if (sock_err != SOCKET_ERROR) {
		printf("Chaine envoyée : Type : %s\n",type);
	}
	else
		perror("Erreur : Type");
 
	sock_err = send(csockDessin, taille, 3, 0);
	if (sock_err != SOCKET_ERROR) {
		printf("Chaine envoyée : Taille : %s\n",taille);
	}
	else
		perror("Erreur : Taille");
 
	sock_err = send(csockDessin, couleurChar, 2, 0);
	if (sock_err != SOCKET_ERROR) {
		printf("Chaine envoyée : Couleur : %s\n",couleurChar);
	}
	else
		perror("Erreur : Couleur");
}
 
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
	if (nbJoueur != 0) {
		mouseSwiped = YES;
		if(sTailleTrait.value>100||sTailleTrait.value<7)
		{
			sTailleTrait.value=30;
		}
 
		UITouch *touch = [touches anyObject];
		CGPoint currentPoint = [touch locationInView:self.view];
		if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
			currentPoint.y -= 90;
		}
		else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
			currentPoint.y -= 200;
		}
		else {
			perror("Erreur d'appareil");
		}
 
		UIGraphicsBeginImageContext(self.view.frame.size);
		[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
		CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
		CGContextSetLineWidth(UIGraphicsGetCurrentContext(), sTailleTrait.value);
		CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
 
CGContextBeginPath(UIGraphicsGetCurrentContext());
		CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
		CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
		CGContextStrokePath(UIGraphicsGetCurrentContext());
		drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
		UIGraphicsEndImageContext();
 
		lastPoint = currentPoint;
 
		strcpy(type, "Move\0");
		convChar = [NSString stringWithFormat:@"%f\0", sTailleTrait.value];
		strcpy(taille, [convChar UTF8String]);
		convChar = [NSString stringWithFormat:@"%d\0", couleur];
		strcpy(couleurChar, [convChar UTF8String]);
		convChar= [NSString stringWithFormat:@"%f\0", lastPoint.x];
		if (lastPoint.x>-100 && lastPoint.x<1000) {
			strcpy(pointX,[convChar UTF8String]);
		}
		convChar = [NSString stringWithFormat:@"%f\0", lastPoint.y];
		if (lastPoint.y>-100 && lastPoint.y<1000) {
			strcpy(pointY,[convChar UTF8String]);
		}
		envoiPoint();
		nbThreadDessin++;
	}
}
 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
	if(!mouseSwiped && nbJoueur!=0) {
		UIGraphicsBeginImageContext(self.view.frame.size);
		[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
		CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
		CGContextSetLineWidth(UIGraphicsGetCurrentContext(), sTailleTrait.value);
		CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
		CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
		CGContextStrokePath(UIGraphicsGetCurrentContext());
		CGContextFlush(UIGraphicsGetCurrentContext());
		drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
		UIGraphicsEndImageContext();
 
		strcpy(type, "End\0");
		convChar = [NSString stringWithFormat:@"%f\0", sTailleTrait.value];
		strcpy(taille, [convChar UTF8String]);
		convChar = [NSString stringWithFormat:@"%d\0", couleur];
		strcpy(couleurChar, [convChar UTF8String]);
		convChar = [NSString stringWithFormat:@"%f\0", lastPoint.x];
		strcpy(pointX,[convChar UTF8String]);
		convChar = [NSString stringWithFormat:@"%f\0", lastPoint.y];
		strcpy(pointY,[convChar UTF8String]);
		envoiPoint();
		nbThreadDessin++;
	}
}
 
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
	NSString * docsDir;
	NSString * path;
 
	UIImage * viewImage;
 
	NSData * imageData;
 
	UIGraphicsBeginImageContext(vDessin.bounds.size);
	[vDessin.layer renderInContext:UIGraphicsGetCurrentContext()];
	viewImage = UIGraphicsGetImageFromCurrentImageContext();
	imageData = UIImagePNGRepresentation(viewImage);
	docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
	path = [docsDir stringByAppendingPathComponent:@"dessin.png"];
	[imageData writeToFile:path atomically:NO];
 
	fermetureConnect();
}
 
void fermetureConnect() {
	int sock_err = 0;
	char fin [5] = "FIN";
 
	for (int i=0; i<10; i++) {
		sock_err = send(csockDessin, fin, 5, 0);
		if (sock_err != SOCKET_ERROR) {
			printf("Chaine envoyée : Fin\n");
		}
		else {
			perror("Fin : ");
		}
	}
 
	shutdown(csockDessin, 2);
 
	/* Fermeture de la socket client et de la socket serveur */
	printf("Fermeture de la socket client\n");
	closesocket(csockDessin);
	printf("Fermeture de la socket serveur\n");
	closesocket(ssockDessin);
	printf("Fermeture du serveur terminée\n");
}
Donc comme vous le voyez, à chaque fois que l'utilisateur 1 touche l'écran, le device envoie une socket contenant les diverses informations utiles pour l'autre device (couleur, taille, position X, position Y).

"Code client, donc utilisateur 2 celui qui doit recevoir le dessin" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
- (void)viewDidLoad
{
    [super viewDidLoad];
	char niv1 = '\0';
	char niv[1] = "";
	char typeP[5] = "";
 
	NSString *docsDir;
	NSString *path;
	NSString *recup;
	NSString *ip;
 
	SOCKADDR_IN sinRep = { 0 };
 
docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/vue"];
	recup = [NSString stringWithContentsOfFile:docsDir encoding:NSUTF8StringEncoding error:nil];
	if ([recup isEqualToString:@"premier"]) {
		drawImage = [[UIImageView alloc] initWithImage:nil];
		drawImage.frame = self.view.frame;
		[self.vDessin addSubview:drawImage];
		self.vDessin.backgroundColor = [UIColor whiteColor];
 
		/* Création de la socket */
		sockRep = socket(AF_INET, SOCK_STREAM, 0);
 
		/* Configuration de la connexion */
		docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/adresse"];
		ip = [NSString stringWithContentsOfFile:docsDir encoding:NSUTF8StringEncoding error:nil];
		sinRep.sin_addr.s_addr = inet_addr([ip UTF8String]);
		sinRep.sin_family = AF_INET;
		sinRep.sin_port = htons(PORT);
		/* Si le client arrive à se connecter */
		if(connect(sockRep, (SOCKADDR*)&sinRep, sizeof(sinRep)) != SOCKET_ERROR)
		{
			printf("Connexion à %s sur le port %d\n", inet_ntoa(sinRep.sin_addr), htons(sinRep.sin_port));
			if(recv(sockRep, typeP, 5, 0) != SOCKET_ERROR)
			{
				printf("Recu : %s\n", typeP);
				docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
				path = [docsDir stringByAppendingPathComponent:@"typePartie"];
				[[NSString stringWithFormat:@"%s",typeP] writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
			}
			else
			{
				perror("???0");
			}
			if(recv(sockRep, niv, 1, 0) != SOCKET_ERROR)
			{
				printf("Recu : %s\n", niv);
				niv1 = niv[0];
				printf("Char : %c\n", niv1);
				docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
				path = [docsDir stringByAppendingPathComponent:@"niveauPartie"];
				[[NSString stringWithFormat:@"%c",niv1] writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
			}
			else
			{
				perror("???1");
			}
			if(recv(sockRep, mot, 14, 0) != SOCKET_ERROR)
			{
				printf("Recu : %s\n", mot);
				docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
				path = [docsDir stringByAppendingPathComponent:@"mot"];
				[[NSString stringWithFormat:@"%s",mot] writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
			}
			else
				perror("???2");
			[self performSelectorInBackground:@selector(receptPoint) withObject:nil];
		}
		else {
			perror("Connect :");
		}
 
		docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/mot"];
		recup = [NSString stringWithContentsOfFile:docsDir encoding:NSUTF8StringEncoding error:nil];
 
-(void) receptPoint
{
	bool continu = true;
	while (continu) {
		if(recv(sockRep, pointX, 5, 0) != SOCKET_ERROR)
		{
			printf("Point X : %s\n",pointX);
		}
		else
		{
			perror("recv1");
		}
		if(recv(sockRep, pointY, 5, 0) != SOCKET_ERROR)
		{
			printf("Point Y : %s\n",pointY);
		}
		else
		{
			perror("recv2");
		}
		if(recv(sockRep, type, 6, 0) != SOCKET_ERROR)
		{
			printf("Type : %s\n",type);
		}
		else
		{
			perror("Type ");
		}
		if(recv(sockRep, taille, 3, 0) != SOCKET_ERROR)
		{
			printf("Taille : %s\n",taille);
		}
		else
		{
			perror("Taille ");
		}
		if(recv(sockRep, couleurChar, 2, 0) != SOCKET_ERROR)
		{
			printf("Couleur : %s\n",couleurChar);
		}
		else
		{
			perror("Couleur ");
		}
		if (pointX[0] == 'F' && pointX[1] == 'I' && pointX[2] == 'N') {
			continu=false;
		}
		else {
			if (!strcmp(type, "Began")) {
				if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
					lastPoint.x = atof(pointX)*2.4;
					lastPoint.y = atof(pointY)*2.2;
				}
				else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
					lastPoint.x = atof(pointX)/2.4;
					lastPoint.y = atof(pointY)/2.2;
				}
				else {
					perror("Erreur d'appareil ");
				}
			}
			else if (!strcmp(type, "Move")) {
 
 
				UIGraphicsBeginImageContext(self.view.frame.size);
				[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
				CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
				if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
					CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof(taille)*2);
				}
				else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
					CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof(taille)/2);
				}
				else {
					perror("Erreur d'appareil ");
				}
                                CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
CGContextBeginPath(UIGraphicsGetCurrentContext());
				CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
				if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
					CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), atof(pointX)*2.4, atof(pointY)*2.2);
				}
				else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
					CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), atof(pointX)/2.4, atof(pointY)/2.2);
				}
				else {
					perror("Erreur d'appareil ");
				}
				CGContextStrokePath(UIGraphicsGetCurrentContext());
				drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
				UIGraphicsEndImageContext();
 
				if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
					lastPoint.x = atof(pointX)*2.4;
					lastPoint.y = atof(pointY)*2.2;
				}
				else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
					lastPoint.x = atof(pointX)/2.4;
					lastPoint.y = atof(pointY)/2.2;
				}
				else {
					perror("Erreur d'appareil ");
				}
			}
			else if (!strcmp(type, "End")) {
				UIGraphicsBeginImageContext(self.view.frame.size);
				[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
				CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
				if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
					CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof(taille)*2);
				}
				else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
					CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof(taille)/2);
				}
				else {
					perror("Erreur d'appareil ");
				}
                                CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
                                CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
				CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
				CGContextStrokePath(UIGraphicsGetCurrentContext());
				CGContextFlush(UIGraphicsGetCurrentContext());
				drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
				UIGraphicsEndImageContext();
			}
		}
	}
	closesocket(sockRep);
}
Ici, comme vous pouvez le voir j'utilise un thread pour permettre de finir l'implémentation de la page tout en commencant à recevoir les données du dessin. Malgré tout, j'aimerais qu'à chaque fois que je reçois les informations, donc à chaque fois que ça reboucle dans le while, j'ai mon point qui s'ajoute sur l'écran. Actuellement, il faut attendre que tout les points soient passés et que le while soit finis pour que la vue se réactualise. Du coup, le device enregistre les informations et les enregistre encore et encore et finit donc par saturer. C'est logique. Mais je ne vois pas comment faire pour faire autrement.

Voilà si quelqu'un s'y connaît bien en Objective-C, prog Ipad/Iphone, prog XCode. Je suis preneur. Je pense commencé à bien maitrisé mais malgré tout je ne vois absolument aucune solution ....

Voilà, merci d'avance.

PS : Petit truc qui n'a pas d'importance d'après moi mais on ne sait jamais. Le bug apparait quand je dessine sur l'Iphone, et que je reçois le dessin sur l'Ipad. Mais absolument pas quand je dessine sur l'Ipad et que je reçois sur l'Iphone...

Edit : J'ai réussi à récupérer le message d'erreur qui apparaît quelques secondes avant le plantage de l'appli client : 2013-05-24 10:17:24.346 Projet Satge V0.7[2755:907] Received memory warning.

Edit 2 : On m'a conseillé de séparer la partie réception de données et la partie graphisme, donc c'est ce que j'ai fais. Je vous met ma fonction "receptPoint" qui se sépare donc en deux fonction : "receptPoint" et "dessine" (les deux sont lancés dans des threads en même temps) :

"receptPoint" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
-(void) receptPoint
{
	int i=0;
	while (continu) {
		if(recv(sockRep, pointX, 5, 0) != SOCKET_ERROR)
		{
			printf("Point X : %s\n",pointX);
			pointXS[i] = [NSString stringWithFormat:@"%s",pointX];
		}
		else
		{
			perror("recv1");
		}
		if(recv(sockRep, pointY, 5, 0) != SOCKET_ERROR)
		{
			printf("Point Y : %s\n",pointY);
			pointYS[i] = [NSString stringWithFormat:@"%s",pointY];
		}
		else
		{
			perror("recv2");
		}
		if(recv(sockRep, type, 6, 0) != SOCKET_ERROR)
		{
			printf("Type : %s\n",type);
			typeS[i] = [NSString stringWithFormat:@"%s",type];
		}
		else
		{
			perror("Type ");
		}
		if(recv(sockRep, taille, 3, 0) != SOCKET_ERROR)
		{
			printf("Taille : %s\n",taille);
			tailleS[i] = [NSString stringWithFormat:@"%s",taille];
		}
		else
		{
			perror("Taille ");
		}
		if(recv(sockRep, couleurChar, 2, 0) != SOCKET_ERROR)
		{
			printf("Couleur : %s\n",couleurChar);
			couleurS[i] = [NSString stringWithFormat:@"%s",couleurChar];
		}
		else
		{
			perror("Couleur ");
		}
		if (pointX[0] == 'F' && pointX[1] == 'I' && pointX[2] == 'N') {
			continu=false;
		}
		i++;
	}
	closesocket(sockRep);
}
"dessine" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
- (void) dessine
{
	int i = 0;
	while (continu) {
		if (typeS[i]!=NULL) {
				if ([typeS[i] isEqual: @"Began"]) {
					if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
						lastPoint.x = atof([pointXS[i] UTF8String])*2.4;
						lastPoint.y = atof([pointYS[i] UTF8String])*2.2;
					}
					else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
						lastPoint.x = atof([pointXS[i] UTF8String])/2.4;
						lastPoint.y = atof([pointYS[i] UTF8String])/2.2;
					}
					else {
						perror("Erreur d'appareil ");
					}
				}
				else if ([typeS[i] isEqual: @"Move"]) {
 
 
					UIGraphicsBeginImageContext(self.view.frame.size);
					[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
					CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
					if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
						CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof([tailleS[i] UTF8String])*2);
					}
					else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
						CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof([tailleS[i] UTF8String])/2);
					}
					else {
						perror("Erreur d'appareil ");
					}
                                  CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
 
CGContextBeginPath(UIGraphicsGetCurrentContext());
					CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
					if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
						CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), atof([pointXS[i] UTF8String])*2.4, atof([pointYS[i] UTF8String])*2.2);
					}
					else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
						CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), atof([pointXS[i] UTF8String])/2.4, atof([pointYS[i] UTF8String])/2.2);
					}
					else {
						perror("Erreur d'appareil ");
					}
					CGContextStrokePath(UIGraphicsGetCurrentContext());
					drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
					UIGraphicsEndImageContext();
 
					if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
						lastPoint.x = atof([pointXS[i] UTF8String])*2.4;
						lastPoint.y = atof([pointYS[i] UTF8String])*2.2;
					}
					else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
						lastPoint.x = atof([pointXS[i] UTF8String])/2.4;
						lastPoint.y = atof([pointYS[i] UTF8String])/2.2;
					}
					else {
						perror("Erreur d'appareil ");
					}
				}
				else if ([typeS[i] isEqual: @"End"]) {
					UIGraphicsBeginImageContext(self.view.frame.size);
					[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
					CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
					if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
						CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof([tailleS[i] UTF8String])*2);
					}
					else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
						CGContextSetLineWidth(UIGraphicsGetCurrentContext(), atof([tailleS[i] UTF8String])/2);
					}
					else {
						perror("Erreur d'appareil ");
					}
						CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.3, 0.2, 0.5, 1.0);
 
					CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
					CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
					CGContextStrokePath(UIGraphicsGetCurrentContext());
					CGContextFlush(UIGraphicsGetCurrentContext());
					drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
					UIGraphicsEndImageContext();
				}
				i++;
		}
	}
}