Hướng dẫn load dữ liệu từ json vào tableView

Ở bài trước mình đã hướng dẫn cho các bạn cách làm thế nào để đọc json từ web Service  và trả về các API.

Tiếp theo trong hướng dẫn này mình sẽ giúp các bạn  làm thế nào để load dữ liệu từ Json vào tableView.

Để đơn giản bài này mình sẽ giúp các bạn:

1,  Đọc title tên bài hát.

2, Đọc file ảnh lên.

đây là đoạn mã json chúng ta đọc ở bài trước:

 favorites =     (
                {
            artist = Brandy;
            "image_large" = "https://i.scdn.co/image/8a161e85351a20aaf4f4099cc89e1b8fb726e035";
            "image_medium" = "https://i.scdn.co/image/3f3b3c7e4d4feabb73c885b38500d1427260ae33";
            "image_small" = "https://i.scdn.co/image/4dcf0d5722e62cdfaf620a773f010e6b2dd15b78";
            "open_url" = "https://open.spotify.com/track/6esN4GvN6uRe1SVVNElHDq";
            "preview_url" = "https://p.scdn.co/mp3-preview/33add4c82a52fbaf7665b8dee3da1c73b2406775";
            "song_id" = 54dd0bc8a57fa90c00770523;
            title = "I Wanna Be Down - Single Version";
        },
                {
            artist = "Destiny's Child";
            "image_large" = "https://i.scdn.co/image/bf0f79acd50add01e88575664fe98d8d44d3123f";
            "image_medium" = "https://i.scdn.co/image/a7aef2e8232955bb94d7c041a0fbc06b2bb8fe7f";
            "image_small" = "https://i.scdn.co/image/fdf76dbe620b71af39d775274795c0ca2829c19f";
            "open_url" = "https://open.spotify.com/track/72oq9xR8MK5CLpI185xaVy";
            "preview_url" = "https://p.scdn.co/mp3-preview/ca5baaecfef5ce51277e105f71a8d63240b734d8";
            "song_id" = 54dd0bc8a57fa90c00770606;
            title = Survivor;
        },
                {
            artist = Fischerspooner;
            "image_large" = "https://i.scdn.co/image/bbae0384d6c3003efe6b913320be17d2236a7ed9";
            "image_medium" = "https://i.scdn.co/image/2e1a1eca7d08deead66e837e07cc434fe8b0262d";
            "image_small" = "https://i.scdn.co/image/f2e566ac0da74bbb65bb0d734a7b8a3366bf4997";
            "open_url" = "https://open.spotify.com/track/4etezwvjIhth11BG1SGCgs";
            "preview_url" = "https://p.scdn.co/mp3-preview/198d749dbeffcbe3e2a63c3d85f0b07fb9539e35";
            "song_id" = 54dd0bc8a57fa90c007705ba;
            title = "Never Win";
        },
                {
            artist = "Kid Sister";
            "image_large" = "https://i.scdn.co/image/a4342e2a38b294db0775d699138af0902fabf25f";
            "image_medium" = "https://i.scdn.co/image/5b17e76a08d1577d900454c4ad2a68313245aa13";
            "image_small" = "https://i.scdn.co/image/3d1c9c17285ffbc91c97d865f6c7e63edfb972c2";
            "open_url" = "https://open.spotify.com/track/7gjsO6qOYqTEXqZJrbIaOG";
            "preview_url" = "https://p.scdn.co/mp3-preview/3edf28271aaa8dbe07496c0f341633d91e779723";
            "song_id" = 54dd0bc8a57fa90c0077062b;
            title = Control;
        },
                {
            artist = "Ellie Goulding";
            "image_large" = "https://i.scdn.co/image/1a3ca29c2f93fa50f72df85b1a94f62383dbc5cd";
            "image_medium" = "https://i.scdn.co/image/253be50ddceb82345cc02d13f68711b1de185936";
            "image_small" = "https://i.scdn.co/image/84496c2807804327b59add2b6bd3957badf74083";
            "open_url" = "https://open.spotify.com/track/6Ks02PwRawUTDwGyboe0Fc";
            "preview_url" = "https://p.scdn.co/mp3-preview/4af7f000411b8959efb6ca6530157752f362abcd";
            "song_id" = 54dd0bc8a57fa90c00770574;
            title = "Lights (Single Version)";
        },
                {
            artist = Ladyhawke;
            "image_large" = "https://i.scdn.co/image/a7d927e5fc59da3923d06d61b7649c0144561481";
            "image_medium" = "https://i.scdn.co/image/845665ec2f35b397c44464f4b8e183faaf11550c";
            "image_small" = "https://i.scdn.co/image/b1037dc2edcf2b4e2c8624e7591580e1d46bd9c7";
            "open_url" = "https://open.spotify.com/track/5eStaIpPvDJCMrWELkSAp5";
            "preview_url" = "https://p.scdn.co/mp3-preview/dad0c35fa3953a720208f1d6d0231c68a139e7db";
            "song_id" = 54dd0bc8a57fa90c007705c7;
            title = "Back Of The Van";
        },
                {
            artist = "Luther Vandross";
            "image_large" = "https://i.scdn.co/image/b2210635a2334ffbba99792888b5a4d25041c228";
            "image_medium" = "https://i.scdn.co/image/499e378a14c8d66601cb764b8b2cd17aa1b82b89";
            "image_small" = "https://i.scdn.co/image/d2b34a04398f4b42236191fab1cc91996577d286";
            "open_url" = "https://open.spotify.com/track/3Bb9jzYKHSOmEM1tikLd6V";
            "preview_url" = "https://p.scdn.co/mp3-preview/3660756c15a4741a9b0671c512b8ce8084eb4590";
            "song_id" = 54dd0bc8a57fa90c00770641;
            title = "Dance With My Father";
        },
                {
            artist = "Ne-Yo";
            "image_large" = "https://i.scdn.co/image/00a3bb46c61c035ddb47502b71da4f062c82804d";
            "image_medium" = "https://i.scdn.co/image/149d0bbd504d0c919da20152636c5dbc8cbb365b";
            "image_small" = "https://i.scdn.co/image/a5e4ed0bc57c4664bb1c8720cc9f7adefd35dca0";
            "open_url" = "https://open.spotify.com/track/2dQAJjOAePdj8hLE88Qp5L";
            "preview_url" = "https://p.scdn.co/mp3-preview/db2e8fbdb875b4c6fca354d2831fe050317edb7f";
            "song_id" = 54dd0bc8a57fa90c007704fe;
            title = "Miss Independent";
        },
                {
            artist = "Brooks & Dunn";
            "image_large" = "https://i.scdn.co/image/aec75b35408f3d3371d183f94adf872c39d04ba3";
            "image_medium" = "https://i.scdn.co/image/a83cfbb35e373129720883eefc750fa11b269108";
            "image_small" = "https://i.scdn.co/image/1336210e9131e57c69e82967def09d45f4b38d1a";
            "open_url" = "https://open.spotify.com/track/09qzRI951OVkXGCc33gzcT";
            "preview_url" = "https://p.scdn.co/mp3-preview/a3405fc8f47de7e9e06a49b8293668dd554af401";
            "song_id" = 54dd0bc8a57fa90c007704e3;
            title = "My Maria";
        },
                {
            artist = "Mila J";
            "image_large" = "https://i.scdn.co/image/93df01f3f7b2080f924b0c4890a82751e16fa8aa";
            "image_medium" = "https://i.scdn.co/image/e97f7b416871f420377e58f1d6d7dec13d7ccb59";
            "image_small" = "https://i.scdn.co/image/f12516b1e7d165c403a41dfb7a931741a17041b1";
            "open_url" = "https://open.spotify.com/track/7slZeIUsewMBnkMXT1RWoh";
            "preview_url" = "https://p.scdn.co/mp3-preview/02816213ba85a87b87f1fead3297448684298988";
            "song_id" = 54dd0bc8a57fa90c00770601;
            title = "Smoke, Drink, Break-Up";
        },
                {
            artist = "Luke Bryan";
            "image_large" = "https://i.scdn.co/image/beb2a1636debd37a16c03a787ea962add845eccb";
            "image_medium" = "https://i.scdn.co/image/045e857dc7d9643ed309fc0b3c5c1bb9d6fe427d";
            "image_small" = "https://i.scdn.co/image/36dad0b9096e1da60518b851eb6a3ca6942143cf";
            "open_url" = "https://open.spotify.com/track/3xn2DXsMWxeJKNiG6IYZsk";
            "preview_url" = "https://p.scdn.co/mp3-preview/779229ac7ca042ce3c2a4d710458665a4c3e4e44";
            "song_id" = 54dd0bc8a57fa90c007704c8;
            title = "What Country Is";
        },
                {
            artist = Alesso;
            "image_large" = "https://i.scdn.co/image/33708105136c9c996aba5c7f75a55c5e412adfe1";
            "image_medium" = "https://i.scdn.co/image/50425bd18161ae9ca646c6286c8fa2bbf2026569";
            "image_small" = "https://i.scdn.co/image/f31193dec0fef99fdb6383e618d29c2bea051942";
            "open_url" = "https://open.spotify.com/track/7rwaGOl65pF5TtW0CxV3HJ";
            "preview_url" = "https://p.scdn.co/mp3-preview/948ac7e96bc2f9ca2280fbab8ffb9f0943d50788";
            "song_id" = 54dd0bc8a57fa90c00770639;
            title = "If I Lose Myself";
        },
                {
            artist = "Marc Ribot";
            "image_large" = "https://i.scdn.co/image/1606d9ec7ff6c90bd4cf26546a02aab0054d337a";
            "image_medium" = "https://i.scdn.co/image/582f04eed1e9a87aa33667dddcb4f784c56030a1";
            "image_small" = "https://i.scdn.co/image/8eb8ffb9a55516a8d324626b288c5c3e0dea31c6";
            "open_url" = "https://open.spotify.com/track/6AMnK19NuloZd3SP78mNic";
            "preview_url" = "https://p.scdn.co/mp3-preview/950c0b08bf6140b47818f5a382d1cdf3570d3859";
            "song_id" = 54dd0bc8a57fa90c007705f5;
            title = Bateau;
        },
                {
            artist = "Trace Adkins";
            "image_large" = "https://i.scdn.co/image/5623dd558033082bdee23baee062b3860e2dc9de";
            "image_medium" = "https://i.scdn.co/image/3729ec348ff835cd3b8d7d05825dfa1f49c375d2";
            "image_small" = "https://i.scdn.co/image/01bec368c5c874934000205803c5febe12374c7f";
            "open_url" = "https://open.spotify.com/track/7l2mYsNQu8zxQ54mcsiXMX";
            "preview_url" = "https://p.scdn.co/mp3-preview/edce600d6ace9367fc12b2a9c873ef08023bf6e6";
            "song_id" = 54dd0bc8a57fa90c007704e1;
            title = Swing;
        },
                {
            artist = "The Naked And Famous";
            "image_large" = "https://i.scdn.co/image/4b8100bab1d9590097b67550777ecef07e78997a";
            "image_medium" = "https://i.scdn.co/image/8130d5a147ee9792cff7a9a23376ac56ff45a01b";
            "image_small" = "https://i.scdn.co/image/962a6b9cec416d4b1a683481fa92f6caeac99f2b";
            "open_url" = "https://open.spotify.com/track/25pnOZSMwZBU7PAgaDS5yi";
            "preview_url" = "https://p.scdn.co/mp3-preview/6e4990a23ebf97f00016d2f670da0065164c2e67";
            "song_id" = 54dd0bc8a57fa90c00770555;
            title = "Young Blood";
        },
                {
            artist = "Gwen Stefani";
            "image_large" = "https://i.scdn.co/image/5e1c2c47bab93b8d2db21d6fd96f6a7f1d167bff";
            "image_medium" = "https://i.scdn.co/image/0b49d63cad634f967cda9e786abc1496ad6457bf";
            "image_small" = "https://i.scdn.co/image/d3ff468f81747eae2bf854e65eaafc596dd5d286";
            "open_url" = "https://open.spotify.com/track/5WguijCseCBLdm67oK6wxQ";
            "preview_url" = "https://p.scdn.co/mp3-preview/839903b38c82726f4a2a48fa90f5b43e75e13f2c";
            "song_id" = 54dd0bc8a57fa90c00770531;
            title = "Hollaback Girl";
        },
                {
            artist = Dio;
            "image_large" = "https://i.scdn.co/image/dd09f80774d71a6bf6d9e64b883b817617399f8a";
            "image_medium" = "https://i.scdn.co/image/b2957d55a6edc4f7c6e89fca8acea036f6179ac0";
            "image_small" = "https://i.scdn.co/image/e19e63a60bd554e4b450f884fb370ad143e8de3d";
            "open_url" = "https://open.spotify.com/track/4w3aNK1WlBwSLtIA0oyLBt";
            "preview_url" = "https://p.scdn.co/mp3-preview/f19c85405fa046aec012b16a8bd37fe2847a5006";
            "song_id" = 54dd0bc8a57fa90c0077065e;
            title = "We Rock";
        },
                {
            artist = "Florida Georgia Line";
            "image_large" = "https://i.scdn.co/image/83cea4f107695769d107ed2cb214f3ec6908a1bd";
            "image_medium" = "https://i.scdn.co/image/a99db44ed24fa2d9ad6dbebeff5fc0cf878b89b6";
            "image_small" = "https://i.scdn.co/image/586fa6b478fde2705f57f0665ace2d474c7a2678";
            "open_url" = "https://open.spotify.com/track/1XPMs9Qm63aOGZ7l0vYgy5";
            "preview_url" = "https://p.scdn.co/mp3-preview/b6fcb34a4982db2b04aad60e37e2d8c502a189eb";
            "song_id" = 54dd0bc8a57fa90c00770595;
            title = "Round Here";
        },
                {
            artist = "Angel Haze";
            "image_large" = "https://i.scdn.co/image/6f9e0ffe9c9e5419f94c6393d431fcc936a63cf9";
            "image_medium" = "https://i.scdn.co/image/25bc68682340006926a27ad8f5485ef592131b48";
            "image_small" = "https://i.scdn.co/image/7521c80c241c579a9ea37e4366df9774c6108f54";
            "open_url" = "https://open.spotify.com/track/5NkVKO5bGag9F4BARCZk3H";
            "preview_url" = "https://p.scdn.co/mp3-preview/05e8647fee917ab464850cdb6fa1ff2798ee2bc4";
            "song_id" = 54dd0bc8a57fa90c0077061c;
            title = "Werkin' Girls";
        },
                {
            artist = "R. Kelly";
            "image_large" = "https://i.scdn.co/image/25e552b5f8731e513db2d4d0a1aab327e3d949bc";
            "image_medium" = "https://i.scdn.co/image/be2928b658a74b815624b089a3808eb660ffd3bb";
            "image_small" = "https://i.scdn.co/image/3f388a9364ef0e8188873f4f5aa068840f2d7dee";
            "open_url" = "https://open.spotify.com/track/6gHpWdXP2cgOhCt4Qe1txI";
            "preview_url" = "https://p.scdn.co/mp3-preview/1f5d6ca2269714055674a8a75a86ae9d9e1f931d";
            "song_id" = 54dd0bc8a57fa90c00770524;
            title = "When A Woman's Fed Up";
        },
                {
            artist = "Florence + The Machine";
            "image_large" = "https://i.scdn.co/image/49cb3777297b69bb88c82abe1ea0d9ae8591ba13";
            "image_medium" = "https://i.scdn.co/image/c68c814e2d5bac478d89060e1221d584dd64afa5";
            "image_small" = "https://i.scdn.co/image/abe9a6ee3a6fe58442e05f63e6d0f68ef6ed85b4";
            "open_url" = "https://open.spotify.com/track/7mpSKT7h6p12YqppsvbMGw";
            "preview_url" = "https://p.scdn.co/mp3-preview/66ea51007160acf9ae53ebf1cf0bca15b4ff865a";
            "song_id" = 54dd0bc8a57fa90c00770564;
            title = "Shake It Out";
        },
                {
            artist = Dio;
            "image_large" = "https://i.scdn.co/image/dd09f80774d71a6bf6d9e64b883b817617399f8a";
            "image_medium" = "https://i.scdn.co/image/b2957d55a6edc4f7c6e89fca8acea036f6179ac0";
            "image_small" = "https://i.scdn.co/image/e19e63a60bd554e4b450f884fb370ad143e8de3d";
            "open_url" = "https://open.spotify.com/track/7zfELzsiLpEy1qGGdTHbYL";
            "preview_url" = "https://p.scdn.co/mp3-preview/47a1a30bc67aa42f1762de71504cc83e55269c4d";
            "song_id" = 54dd0bc8a57fa90c0077064c;
            title = "The Last In Line";
        },
                {
            artist = Journey;
            "image_large" = "https://i.scdn.co/image/b06e3c992e0f5c8b1333156f6c6e970c63979831";
            "image_medium" = "https://i.scdn.co/image/99ca079c3e371e25d85e5fa3c0bb4c0507e2e340";
            "image_small" = "https://i.scdn.co/image/a96dc5a85b6fca75c953ecffb68ff7822899294a";
            "open_url" = "https://open.spotify.com/track/0SX3NGWlnGuVrp7bx0TaW3";
            "preview_url" = "https://p.scdn.co/mp3-preview/5143697bf4ecc4edebab728edcc359bd3558ebb6";
            "song_id" = 54dd0bc8a57fa90c007704c5;
            title = "Separate Ways";
        }
    );
    "session_id" = 56c440c9e747e31100274a86;
    username = hiep;
}

Với tham số truyền vào là hiệp!. Ở đây tôi đơn giản là làm với session !!!

chúng ta thay đổi đoạn mã sau!

để tham số truyền vào là method và para và trả về một block còn c

-(void)urlSession:(NSString*)method paras:(NSDictionary *)para: (void(^)(NSError *error,NSDictionary *dictInfor))completion{
    NSURL *url=[NSURL URLWithString:@"https://ionic-songhop.herokuapp.com/login"];
    NSMutableURLRequest *request= [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:method];
    if (para!=nil) {
        NSMutableArray *endcodeParaCompos =[[NSMutableArray alloc]init];
        for (NSString *key in para) {
            [endcodeParaCompos addObject:[NSString stringWithFormat:@"%@=%@",key,para[key]]];
        }
        NSData *encodeParas=[[endcodeParaCompos componentsJoinedByString:@"&"] dataUsingEncoding:NSUTF8StringEncoding];
        [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        [request setValue:[NSString stringWithFormat:@"%d",(int)encodeParas.length] forHTTPHeaderField:@"Content-Length"];
        request.HTTPBody=encodeParas;
    }
    
    NSURLSessionDataTask *task=[[NSURLSession sharedSession]dataTaskWithRequest:request completionHandler:^(NSData * data, NSURLResponse *response, NSError *error) {
        NSError *errorData;
        if (error==nil) {
            NSDictionary *conten=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&errorData];
            if (errorData==nil) {
                completion(nil,conten);
            }else{
                NSString *contenError=[[NSString alloc] initWithData:data   encoding:NSUTF8StringEncoding];
                completion(error,nil);
            }
        }
    }];
    [task resume];
}

ok mình sẽ thiết kế giao diện như sau:

Screen Shot 2016-05-25 at 9.19.54 AM

tạo naviagation cho ViewController 

tạo một viewController mới và Kéo từ NSURLSession đến viewcontroller vừa tạo.

tạo class inforViewController quản lý ViewController vừa tạo ra! kết nối class.

Tại inforViewController ta thêm tableView  và thêm tablewViewCell, thêm image và label cho TableViewCell!

Ở đây mình không hướng dẫn cụ thể lại mà chỉ rõ các UI cần làm!!! 

đặt identifine cho cell là “cell”

Kết nối delegate, dataSource cho tableView !

đăng ký delegate,dataSource cho inforViewController.

Ánh xạ tablewView sang class quản lý!

tạo class contenView quản lý label và image!và ánh xạ chúng sang.

Để tiếp kiệm thời gian bạn tải dự án mẫu tại đây:

http://www.mediafire.com/download/9l7ddcz3c0mdl42/Json+4.zip

 

tại file  “inforViewController.h”

#import "ViewController.h"

để tạo đối tượng gọi đến session!

– Đầu tiên tạo tham số truyền vào và mehtod!

tạo một đối tượng controller , trong block chúng ta không được quản lý bộ nhớ theo Strong mà phải quản lý theo weak để app không bị treo. OK. để hiểu rõ quản lý bộ nhớ mình sẽ hướng dẫn các bạn sau!

- (void)viewDidLoad {
    [super viewDidLoad];
    NSDictionary *key=@{@"username":@"hiep"};
    NSString *method=@"POST";
    ViewController *controller=[[ViewController alloc] init];
    __weak inforViewController *weakSelf=self;
    [controller urlSession:method paras:key :^(NSError *error, NSDictionary *dictInfor) {
        [[NSOperationQueue mainQueue]addOperationWithBlock:^{
            weakSelf.favorites=dictInfor[@"favorites"];
            NSLog(@"%@",dictInfor);
            [weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
        }];
        
    }];
}

controller gọi đến hàm urlSession và tuyền vào tham số! method . Khi dữ liệu tải về lưu trong dictInfor. Khi nào dữ liệu tải về thành công mình sẽ trả về block để reloadSesions .Lưu ý phải dùng NSOperationQueue khi đó dữ liệu tải thành công mới load vào tableView nếu không tableView sẽ bị chờ load dữ liệu.

Tiếp theo mình cần làm việc với bảng dữ liệu! có 2 phương thức bắt buộc trong tablewView:

– Trả về số lượng Row trong một section.

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.favorites count];
}

– Trả về data cho tablewView:

Ở đây để đơn giản đầu tiên mình trả về title các bài hát !

tableView dùng như thế nào mình đã hướng dẫn ở các bài trước

do json trả về là một mảng các NSDictionary nên ta tạo một đối tượng item mỗi lần gọi row item được gán lại giá trị.

Json trả về title có key =”title”.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    contenView *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    NSDictionary *item=self.favorites[indexPath.row];
    cell.labelText.text=item[@"title"];
    return cell;
}

biên dịch và chạy thử ta sẽ được kết quả như hình:

Screen Shot 2016-05-25 at 12.03.15 PM

 

Load ảnh vào imageView:

do Json trả về ảnh là các đường dẫn , mà imageView hỗ trợ load ảnh từ data, truyền vào data chuyển đổi thành UIImage.

Thêm đoạn mã sau: load tương tự như API ban đầu tham số truyền vào là đường dẫn ảnh và trả về block lưu trữ UIImage.

-(void) loadImage:(NSString *)strUrl API:(void (^)(UIImage *iconImage))completion{
    NSURL*url=[NSURL URLWithString:strUrl];
    NSURLRequest *request=[NSURLRequest requestWithURL:url];
    NSURLSessionTask*task=[[NSURLSession sharedSession]dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        if (error==nil) {
            UIImage *image=[UIImage imageWithData:data];
            completion(image);
        }
    }];
    [task resume];
}

Trong phương thức CellForRowAtIndexPath thêm đoạn mã sau ngay sau khi set tittle cho label:

[self loadImage:item[@"image_small"] API:^(UIImage *iconImage) {
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
            cell.imageIcon.image=iconImage;
        }];
    }];

Truyền vào key= image_small chúng ta chỉ lấy ảnh kích thước nhỏ. Khi dữ liệu được tải thành công về ta mới xét ảnh vào imageView (imageIcon).

biên dịch và chạy thử :

Screen Shot 2016-05-25 at 12.45.17 PM

 

các bạn cũng thể chạy nhạc để nghe…
Full code :

http://www.mediafire.com/download/6a5ids6r3vgxw73/Json+5.zip

Phần tiếp theo mình sẽ giơi thiệu các bạn cách tạo banner quảng cáo !!! Làm sao để kiếm tiền với  App free download

  • Nếu các bạn muốn biết thêm các kỹ thuật khác về ios, các bạn có thể tham khảo thêm các khóa học ios tại đây.

 

 

Add a Comment

Your email address will not be published. Required fields are marked *