Cocoa / Obj-C简单XML文件阅读器 - 需要帮助 [英] Cocoa/Obj-C simple XML file reader - need help

查看:148
本文介绍了Cocoa / Obj-C简单XML文件阅读器 - 需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天问了一个问题,我想用Cocoa / Obj-C(Xcode)为OSX做一个小应用程序。

I asked a question yesterday about a little app that I would like to make for OSX with Cocoa/Obj-C (Xcode).

原理很简单:

有这样的XML文件:

The princip is easy:
Got an XML file like this one:

<?xml version="1.0" ?>
<Report>
    <Date>20110311</Date>
    <Title>The Title</Title>
    <Description>Description sample<Description>
</Report>

当应用程序打开时,有一个带有三个文本字段的窗口。

加载文件(文件 - >打开)时,三个文本字段获取XML元素中的值。
对于我的例子,它将是:

When the app is opened, there is a window with three text fields.
When a file is loaded (File -> Open) the three text fields get the value of what is in the XML elements.
For my example it will be:

TextFields 1 => 20110311
TextFields 2 => / strong>
TextFields 3 => 说明示例

TextFields 1 => 20110311
TextFields 2 => The Title
TextFields 3 => Description sample

就是这样!

正如你在我的描述中可以看到的,这可能很容易...

但我尝试了很多东西,我没有成功:/

我是Cocoa开发中的新手,有很多专门的东西,我不明白,我该如何在CODE& GUI ...


现在这里是我的需求:

如果有人可以让我做一个类似我上面的例子的Xcode项目,看看我的不同的trys有什么问题,或解释我如何这个应用程序可以完成(与代码示例)...

我花了4个长时间在该项目,但没有结果:(

帮助... :(

Miskia

And that's it!
As you can see in my description, it's maybe easy...
But I tried a lot of things, I didn't successed :/
I'm a newbie in Cocoa developpment and there's a lot of dedicated things that I don't understand like how can I make links between CODE & GUI...

Now here is my demand:
If someone could make me an Xcode project similar to my example above, for see what's wrong with my different trys, or explain me how this app can be done (with codes examples)...
I've spend 4 long days on that project but didn't have results :(
Help... :(
Miskia

推荐答案

示例项目:

http://dd5.org/static/XML.zip

如何创建如上所示的项目:

- 创建新项目

- 添加代码到标题(.h)和实现(.m)文件< br>
- 设计主窗口

- 最后添加正确的绑定

How to create a project like above:
- Create new project
- Add code to the header (.h) and implementation (.m) files
- Design the main window
- Finally add the correct bindings

查看下面的图像如何添加绑定(已在示例项目中完成)。

右键单击App Delegate(应用程序委托)拖动到NSTextFied(图1)。

释放按钮并在光线中选择正确的条目

See images below how to add the bindings (already done in the sample project).
Right-click on the App Delegate drag to the NSTextFied (Picture 1).
Release the button and select the correct entry in the ray menu (Picture 2).


这篇关于Cocoa / Obj-C简单XML文件阅读器 - 需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆