zoukankan      html  css  js  c++  java
  • 使用code::blocks搭建objective-c的IDE开发环境 支持 @interface

    网上有许多的关于 《使用code::blocks搭建objective-c的IDE开发环境》的文章。

    大多是写了一个Helloworld 就结束了,今天试了试 添加了一个 @interface,就是加一个 .h 文件 和一个 .m文件。编译时报错 

    Project 结构:

    main.m

     1 #import <Foundation/Foundation.h>
     2 #include "Person.h"
     3 
     4 int main (int argc, const char *argv[])
     5 {
     6     Person *person = [Person new];
     7     [person Printme :@"Windy" Age:34];
     8 
     9     return 0;
    10 }
    View Code

    Person.h

    1  #import <Foundation/Foundation.h>
    2  @interface Person : NSObject
    3  {
    4     //TODO:
    5  }
    6  -(void) Printme :(NSString*) name Age:(int) age;
    7  @end
    View Code

    Person.m

    1 #include "Person.h"
    2 @implementation Person
    3  -(void) Printme :(NSString*) name Age:(int) age
    4  {
    5      NSLog(@"My name is %@, I am %d old",name,age);
    6  }
    7 @end
    View Code

    编译出错:objDebugmain.o:main.m:(.data+0x58)||undefined reference to `__objc_class_name_Person|.

    代码是没问题的,就是少了一下步骤:

     将 "Person.m"文件的 "Compile File" 和 "Link File" 勾上.

    选中"Person.m"->右键->"Properties..."->"Build"选项

    Ok,搞定!

  • 相关阅读:
    React.memo()使用教程
    React组件什么时候render
    redux-thunk使用教程
    Redux数据持久化
    Mac 中安装 nvm: 切换Node 不同版本
    上传文件类型选择
    Python获取软件安装列表
    Java读取text文件
    负载均衡
    远程调用
  • 原文地址:https://www.cnblogs.com/windyliu/p/3605276.html
Copyright © 2011-2022 走看看