Bonjour,

Je code en ObjC afin de créer une petite application IPhone à titre privé.
J'arrive à scanner des QR-Code qui me rendent des chiffres.
Il faut que je passe ce chiffre dans une autre vue afin de le placer dans une url.

Cependant, je n'y arrive pas… j'ai essayé de faire des méthodes get et de les récupérer mais pas moyen.

Voici mon code:
Ici j'arrive a savoir quel chiffre a été scanner depuis le QR-code.
Code :
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
#import "ViewControllerScan.h"

@interface ViewControllerScan ()
@end

@implementation ViewControllerScan
@synthesize resultImage, resultText;



- (IBAction) scanButtonTapped
{
    
    // ADD: present a barcode reader that scans from the camera feed
    ZBarReaderViewController *reader = [ZBarReaderViewController new];
    reader.readerDelegate = self;
    reader.supportedOrientationsMask = ZBarOrientationMaskAll;
    
    ZBarImageScanner *scanner = reader.scanner;
    // TODO: (optional) additional reader configuration here
    
    
    [scanner setSymbology: ZBAR_QRCODE
                   config: ZBAR_CFG_X_DENSITY
                       to: 2];
    
    [scanner setSymbology:ZBAR_QRCODE 
                   config:ZBAR_CFG_Y_DENSITY 
                       to:2];
    
    reader.readerView.zoom = 1;
    
    reader.scanCrop= CGRectMake(0, 0, 1, 1);
    
    // present and release the controller
    [self presentModalViewController: reader
                            animated: YES];
    
    NSLog(@"je suis là");
}

- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    
    id <NSFastEnumeration> results =
    [info objectForKey: ZBarReaderControllerResults];
    assert(results);
    
    UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
    assert(image);
    if(image)
        resultImage.image = image;
    
    ZBarSymbol *symbol = nil;
    for(symbol in results){
        resultText.text = symbol.data;
        break;
    }
    
    NSString* resultat = resultText.text;
  
    
    NSLog(@"data=%@\n", symbol.data);
    NSLog(@"TEXTE = %@", resultText.text);
   
    NSLog(@"ESSAI = %@", resultat);
    
    // ADD: dismiss the controller (NB dismiss from the *reader*!)
    [reader dismissModalViewControllerAnimated: YES];
}



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
Ici j'aimerai récupérer le chiffre afin de le placer dans l'URL
Code :
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
#import "ViewControllerData.h"
#import "ViewControllerDataDetail.h"
#import "Data.h"

@interface ViewControllerData ()

@end

@implementation ViewControllerData



- (void)loadTimeline {

    // Charger le modèle via RestKit
    RKObjectManager* objectManager = [RKObjectManager sharedManager];
    objectManager.client.baseURL = [RKURL URLWithString: @"http://localhost:8080/CulturalNetworksMuseumServer/resources"];
    [objectManager loadObjectsAtResourcePath:@"/compositecards/1/artifactcards" delegate:self];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
 
    RKLogConfigureByName("RestKit/Network*", RKLogLevelTrace);
    RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
    
    // Initialisation de RestKit
    RKObjectManager* objectManager = [RKObjectManager managerWithBaseURLString:@"http://localhost:8080/CulturalNetworksMuseumServer/resources"];
    
    // Active la gestion automatique de l'indicateur de l'activité réseau
    objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES;
    
    //Configuration du mappage de l'objet Data
    RKObjectMapping * dataMapping = [RKObjectMapping mappingForClass:[Data class]];
    [dataMapping mapKeyPath:@"id" toAttribute:@"ac_id"];
    [dataMapping mapKeyPath:@"file" toAttribute:@"ac_file"];
    [dataMapping mapKeyPath:@"typefile" toAttribute:@"ac_typefile"];
    [dataMapping mapKeyPath:@"author" toAttribute:@"ac_author"];
    [dataMapping mapKeyPath:@"titleTopic" toAttribute:@"ac_titleTopic"];
    [dataMapping mapKeyPath:@"year" toAttribute:@"ac_year"];
    [dataMapping mapKeyPath:@"technical" toAttribute:@"ac_technical"];
    [dataMapping mapKeyPath:@"supportMedia" toAttribute:@"ac_supportMedia"];
    [dataMapping mapKeyPath:@"format" toAttribute:@"ac_format"];
    [dataMapping mapKeyPath:@"owner" toAttribute:@"ac_owner"];
    [dataMapping mapKeyPath:@"collection" toAttribute:@"ac_collection"];
    [dataMapping mapKeyPath:@"remarks" toAttribute:@"ac_descritpionRemarks"];
    
    
    // Permet de mapper l'objet Data avec la source de ce dernier
    [objectManager.mappingProvider setObjectMapping:dataMapping forResourcePathPattern:@"/compositecards/1/artifactcards"];
    
    NSString * test = @"Mappage dans la View Controller";
    NSLog(@"%@",test);
    
    
    // mise en place d'une TableView
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self.view addSubview:_tableView];
    
    // appel de la fonction qui charge le modèle
    [self loadTimeline];
    
    
}

#pragma mark RKObjectLoaderDelegate methods
- (void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response
{
    NSLog(@"Loaded payload: %@", [response bodyAsString]);
}  

/**
 ** Permet de charger la liste des adresses provenant des services Rest sous forme de tableau
 ** Remplir le tableau _data (local) avec le tableau d'objects
 ** Mettre à jour la TableView
 **/
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects {
    NSLog(@"Load collection of ArtifactCards: %@", objects);
    _data = [NSArray arrayWithArray:objects];
    [_tableView reloadData];
}

- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error {
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    NSLog(@"Hit error: %@", error);
}

#pragma mark UITableViewDataSource methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
    return [_data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString* reuseIdentifier = @"Artifact Cell";
    UITableViewCell* cell = [_tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (nil == cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
        cell.textLabel.numberOfLines = 0;
        cell.textLabel.backgroundColor = [UIColor clearColor];
    }
    Data *data = [_data objectAtIndex:indexPath.row];
    
    //[cell.textLabel setText:[NSString stringWithFormat:@"%@ %@", address.ad_lat, address.ad_lon]];
    [cell.textLabel setText:[NSString stringWithFormat:@"%@", data.ac_titleTopic]];
    [cell.detailTextLabel setText:[NSString stringWithFormat:@"%@", data.ac_author]];
//    [cell.detailTextLabel setText:[NSString stringURL:@"%@", data.ac_file]];
//    NSString *stringURL = @"%@", data.ac_file;
//    NSURL *url = [NSURL URLWithString:stringURL];
//    [[UIApplication sharedApplication] openURL:url];
    
    
    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSURL *uneImage = [NSURL URLWithString:@"http://localhost/CulturalNetworksMuseumClient/upload/50190d84bf34aCN.png"];
    
    
    
    UIImageView * monImage = [[UIImageView alloc] initWithFrame: CGRectMake(20, 20, 260, 300)];
    //UIImage *logoImage = [UIImage imageNamed:@"Audio.png"];
    UIImage *logoImage = [UIImage imageWithData: [NSData dataWithContentsOfURL:uneImage]];
    monImage.image = logoImage;
    
   
    [monImage setBackgroundColor: [UIColor lightGrayColor]];
    
    [self.view addSubview:monImage];
    
//    UIView * red = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)];
//    [red setBackgroundColor:[UIColor lighGrayColor]];
//    [self.view addSubview:red];
    
//    ViewControllerDataDetail *detail = [ViewControllerDataDetail alloc];
//    
//    
//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"BRavo" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
//    [alert show];
//    
//    
//    //verifier si il y a animated:YES cela permet de rajouter un effet glissant
//    [self.navigationController pushViewController: detail  animated:YES];
}


- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}


@end