小编gen*_*nie的帖子

Obj-c中的typedef结构

我看到一种奇怪的行为,我需要一些帮助.

在structure.h我有:

typedef struct {
    NSString *summary;
    NSArray *legs;
    NSString *copyrights;
    struct polylineSruct overview_polyline;
    struct directionBounds bounds;    
} route;

typedef struct {
    NSArray *routes;
    NSString *status;
} directions;
Run Code Online (Sandbox Code Playgroud)

在结构中,我有:

(directions) a_Function_that_builds_the_struct
{
    directions direct;

    direct.status = @"OK";

    NSMutableArray *routes = [NSMutableArray array];
    for(xxx)
    {
        route routeL;
        routeL.summary = @"1";
        routeL.copyrights = @"2";

        NSValue *boxedroute = [NSValue valueWithBytes:&routeL objCType:@encode(route)];
        [routes addObject:boxedroute];
    }

    direct.routes = routes;

    return direct;
}
Run Code Online (Sandbox Code Playgroud)

在list_itemsViewController.h我有:

implementation XXX:YYY{
    directions directionsLoc;
}
@property (assign) directions directionsLoc;
Run Code Online (Sandbox Code Playgroud)

在list_itemsViewController.h我有:

@synthesize directionsLoc; …
Run Code Online (Sandbox Code Playgroud)

struct typedef objective-c ios

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

ios ×1

objective-c ×1

struct ×1

typedef ×1