Stanford Cource(2)Demo App Caculator
Recall all the IOS informations.
APNS1~4
http://sillycat.iteye.com/blog/1769158
http://sillycat.iteye.com/blog/1769163
http://sillycat.iteye.com/blog/1769781
http://sillycat.iteye.com/blog/1849217
Envrionment 1~2
http://sillycat.iteye.com/blog/1286175
http://sillycat.iteye.com/blog/1286178
Stanford Cource 1
http://sillycat.iteye.com/blog/1747763
Label, button and a lot of widgets which like VB to me.
Controller will take to the Label in View Ctrl + drag ----> Outlet ----> name display
Button in the View send message to the Controller Ctrl + drag -----> Target ----> digit press
When we copy and paste the button, we copy all the Target.
id is very important in Object-C, it can point to any object. Any Object can be id.
- (IBAction)digitpressed:(UIButton *)sender
{
NSString *digit = sender.currentTitle;
…snip…
}
local variable, NSString
Put console log
NSLog(@"Digit pressed = %@", digit);
UILabel *myDisplay = self.display;
A pointer to the UILabel
NSString *currentText = myDisplay.text;
Get the text of the display
Option + click can give us tip for help.
NSString *newText = [currentText stringByAppendingString:digit];
myDisplay.text = newText;
NSString append the string, and myDisplay call the setText method to update the appending new digit.
Private property in the implementation
@interface CalculatorViewController () @property (nonatomic) BOOL userIsInTheMiddleOfEnterANumber; @property (nonatomic, strong) CalculatorBrain *brain;
@end
Use a local Array in Object C
@interface CalculatorBrain() @property (nonatomic, strong) NSMutableArray *operandStack; @end@implementation CalculatorBrain
@synthesize operandStack = _operandStack;
Add object to Array
[self.operandStack addObject:operandObject];
Make a double number an object
NSNumber *operandObject = [NSNumber numberWithDouble:operand];
Make sure the stack/array is not nil in the getter
-(NSMutableArray *)operandStack{ if(_operandStack == nil){ _operandStack = [[NSMutableArray alloc] init]; } return_operandStack;
}
Get the last digit of the stack
NSNumber *operandObject = self.operandStack.lastObject;if(operandObject){ //check if there is at least one object there [self.operandStack removeLastObject];}
return operandObject.doubleValue;
NSString equal
if([operation isEqualToString:@"+"]){ result = [self popOperand] + [self popOperand];}elseif ([operation isEqualToString:@"-"]){ result = [self popOperand] - [self popOperand];}elseif ([operation isEqualToString: @"*"]){ result = [self popOperand] * [self popOperand];}elseif([operation isEqualToString: @"/"]){ result = [self popOperand] / [self popOperand];
}
Try to convert the String to doubleValue
[self.brain pushOperand:[self.display.text doubleValue]];
References:
http://www.cocoachina.com/iphonedev/toolthain/2011/1019/3387.html
http://tangqiaoboy.blog.163.com/blog/static/11611425820111013102549814/
- 浏览: 2492658 次
- 性别:
- 来自: 成都
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
相关推荐
Coursera-机器学习-斯坦福大学:机器学习-斯坦福大学
C#下调用Stanford CoreNLP,实现中文分词,命名实体识别,词性判断.附件中只包含如何调用,需自行从stanford官网下载模型和语料
Stanford noc的RTL级代码,对应其booksim2
斯坦福 stanford CS468 : Machine Learning for 3D Data课件,第二部分。
Stanford Sentiment Treebank 是一个标准情感数据集,主要用于情感分类,其中每个句子分析树的节点均有细粒度的情感注解。 该数据集由斯坦福大学的 NLP 组发布,其中句子和短语共计 239232 条,相较于忽略单词顺序...
Stanford Graphics:美国斯坦福大学很好用的数据处理软件Stanford Graphics,可以利用数据完美作图。 安装说明:在0文件夹里选择安装INSTALLv.EXE文件,出现窗口提示的时候,依次输入1、2、3、4即可,输入四次后,...
stanford tregex 与stanford parser 结合分析做语言处理用
Revised for the Stanford Parser v. 3.7.0 in September 2016 Stanford parser的类型依赖说明
《NLP汉语自然语言处理原理与实践》...本文针对书中第24页“安装StanfordNLP并编写Python接口类”部分的程序,列出在版本升级后出现的问题,以及相应的解决方案。本文也可以单独作为学习StanfordNLP工具包的学习文档。
Stanford大学编译原理课件,Alex Aiken主讲
stanford-corenlp-3.9.2-models.jar
Stanford iPhone Application Development Course 史丹福iPhone開發教程資料彙整分享. First Assignment • First assignment handed out today, 2 parts • Intended to get you situated with tools and start ...
这是《听说越来越卷,那我们就用卷积神经网络CNN来识别狗狗吧!!》这篇博文中所使用的数据集,免费放在这里供大家使用了啦。
Linux环境下写的。用了Stanford的库,wordladder以及randomwritter,仅供新手参考,有问题大家一起交流
stanford online course Stanford EE214 Lecture 1
斯坦福车 196 类测试集,图片按类别文件夹存放,完整数据集下载: https://github.com/cyizhuo/Stanford-Cars-dataset
斯坦福车 196 类 训练集,图片按类别文件夹存放,完整数据集下载: https://github.com/cyizhuo/Stanford-Cars-dataset
StanfordPaRser
steve jobs stanford speech Steve Jobs, CEO of Apple Computer and Pixar addresses the Stanford University graduating class of 2005 at commencement exercises in June.
Stanford Open Course-Machine Learning