-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLA.m
150 lines (96 loc) · 3.98 KB
/
LA.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
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
//
// LA.m
// Esqueleto DCU
//
// Created by julio.guzman on 18/11/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
// Vista tipo Grid a 3 Columnas
/*
Descripción/Datos que utiliza
Entrada:
Se alimenta de los datos obtenidos por un servicio web
Acción:
Construye la vista con los titulos del autory las imágenes en un grid a 3 columans por N filas
Salida:
Al dar click en un elemento nos lleva a la descripción del mismo
Al dar click en los botones inferiores nos lleva a la vista correcpondiente.
*/
#import "LA.h"
#import "StandardInputTableViewItem.h"
#import "SBJSON.h"
#import "UIImageString.h"
#define IMAGEURL @"http://www.descargacultura.unam.mx/images/mp3Icons/"
@implementation LA
@synthesize ID = _ID;
@synthesize categoryName = _categoryName;
@synthesize label1;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil idNumber:(NSString *)idNumber categoryName:(NSString *)name
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
_ID = idNumber;
_categoryName = name;
[categoryName retain];
[_ID retain];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
scrollable = false;
numberofbuttonsperrow = 3;
buttonheight = 80;
yspacebetweenbuttons = 15;
///
labelx= 15 ;
labely = 10;
labelheight = 25;
tableViewOutlet.showsHorizontalScrollIndicator = NO;
[activityIndicator startAnimating];
[NSThread detachNewThreadSelector:@selector(parse) toTarget:self withObject:nil];
}
-(void)parse{
//CODIGO DE PRUEBA YES
//if( [self reachability])
//HARD CODE
@try
{
standardinputtableviewarray = [[NSMutableArray alloc] init];
StandardInputTableViewItem *siftitem = [[StandardInputTableViewItem alloc] init];
siftitem.imagedictionary = [[NSMutableDictionary alloc] init];
siftitem.stringdictionary =[[NSMutableDictionary alloc] init];
[label1 setText:_categoryName];
//[siftitem.stringdictionary setObject:_categoryName forKey:@"title"];
// LA PARTE DEL PASER
SBJSON *parser = [[SBJSON alloc] init];
//NSLog(@"_ID : : %@", _ID);
NSString *string = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.unam360.com/dcu/service/lista?tipo=autor&id=%@", _ID]] encoding:NSISOLatin1StringEncoding error:nil];
//NSLog(@"string ::%@",string);
NSMutableDictionary *arra = [parser objectWithString:string error:nil];
NSMutableArray *temp = (NSMutableArray *) [arra objectForKey:@"datos"];
//NSLog(@"temp: %@",temp );
for(int i=0 ; i<[temp count]-1;i++){
//Usar herencia para tagear las imagenes.
UIImageString *imagestring = [[UIImageString alloc] init];
imagestring.image = [UIImage imageNamed:@"Cultura-UNAM-38.png"];
imagestring.string = [[NSString alloc] initWithString:[[temp objectAtIndex:i] objectForKey:@"id"]];
if (imagestring.string != nil)
//NSLog(@"id : %@",imagestring.string);
[siftitem.imagedictionary setObject:imagestring forKey:[IMAGEURL stringByAppendingString:[[temp objectAtIndex:i] objectForKey:@"image"]]];
}
[standardinputtableviewarray addObject:siftitem];
}
@catch (NSException *exception) {
[self parse];
}
[tableViewOutlet reloadData];
[activityIndicator setHidesWhenStopped:YES];
[activityIndicator stopAnimating];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//NSLog(@"standardinputtableviewarray %@", standardinputtableviewarray);
return 1;
}
@end