ios 该不该加self

修改self.view为UIScrollView利用ios7 automaticallyAdjustsScrollViewInsets适配ios6、ios7版本 做项目的同时不忘分享自己的 阅读详情

纠结了两天的问题,终于找到原因了!

错误情形:类的成员变量NSArray array.经过@property(nonatomic,copy)和@synthesize。

在类的初始化方法里对array赋值array=[result objectForKey:@"list"];

打印array:NSLog(@"array is %@",array);结果正常。

然后将array作为tableview的数据源,一直出现问题。

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(array!=nil){

        NSLog(@"array is %@",array);
        return [array count];
    }else{
        return 1;
    }
}

打印都会报错。

然后在array的赋值语句里加了个retain,问题竟然解决了。

array=[[result objectForKey:@"list"]retain]或者在array前加上self.

self.array=[result objectForKey:@"list"].也行。

所以调用self.成员变量,这个成员变量的retain会加1的,切记。

因此像self.A=[A alloc]init]这样的代码很可能会crash的。

iOS8新特性Self Sizing Cells,使用estimatedRowHeight自适应cell 阅读详情

相关推荐

Type-C快充移动电源芯片避坑指南:IP5356配置全流程(支持PD3.0)

本文详细解析了英集芯IP5356芯片在Type-C快充移动电源中的应用,提供了从芯片选型、原理图设计、PCB布局到PD协议调试的全流程实战指南。文章重点剖析了如何避免散热、EMI及协议握手等常见设计陷阱,并分享了量产前的关键测试验证方法,旨在帮助硬件开发者高效打造稳定可靠的快充产品。

weixin_29235525的博客 845

Python 方法中变量加self和不加的区别

这段代码我觉得很好的说明了python中类的方法在加self和不加self的区别。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

SmallTankPy的博客 2万+

ARM Cortex平台NEON指令集优化实战指南

本文为ARM Cortex平台开发者提供了一份全面的NEON指令集优化实战指南。文章从NEON的SIMD架构原理讲起,详细介绍了开发环境搭建、NEON内联函数与自动向量化两种核心编程方法、关键数据类型与指令,并通过图像饱和运算、矩阵乘法等实战案例,深入解析了性能调优技巧与常见避坑指南,旨在帮助开发者充分释放ARM处理器的并行计算潜力。

weixin_29162439的博客 259

objective-c 关于 self 的用法总结

何时使用self.在网上搜索或者论坛里的回复大多都是简简单单的说这与objc的存取方法有关,如何与存取方式有关究竟他们之间的是什么样的关系就很少有同学回答了。下面以代码来说明问题: 创建一个Student类,继承NSObject 01 #import 02 03 @ interface S

600

Android开发者必看:5分钟搞定MQTT客户端连接EMQX服务器(附完整代码)

本文为Android开发者提供了一份快速实现MQTT客户端连接EMQX服务器的实战指南。通过引入Eclipse Paho SDK,详细讲解了从项目配置、权限申请到核心连接、主题订阅与消息发布的完整流程,并附有即拿即用的Kotlin代码,帮助开发者在物联网应用中高效集成轻量级实时通信功能。

weixin_29228781的博客 270

【Agent】多智能体框架MetaGPT入门教程

创建一个 Action 类的子类 SimpleWriteCode,子类中定义好 prompt,并解析返回结果。在 MetaGPT 中,

酒酿小圆子呀~ 3133

iOS 提示用self替换_的警告

https://stackoverflow.com/questions/21577711/block-implicitly-retains-self-explicitly-mention-self-to-indicate-this-is-iBuilding Settings CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF=NO

a123473915的专栏 8698

用Matlab机器人工具箱搞定六轴机械臂建模:从DH参数到3D可视化(附完整代码)

本文详细介绍了如何使用Matlab机器人工具箱进行六轴机械臂建模,从DH参数输入到3D可视化全流程解析。通过正运动学验证、逆运动学求解和交互控制等实战技巧,帮助工程师快速掌握机械臂建模核心方法,并提供完整代码示例解决常见问题。

weixin_27372101的博客 394

iOS 开发中的 Self-Manager 模式

2015年12月19日 Self-Manager源于我们团队内部的黑话,“诶?你刚去的创业公司有几个 iOS 开发啊?” “就我一个” “靠,你这是 Self-Manager 啊” 最近,这个思路被我们当做了一种设计模式,即赋予一个 Widget 更大的权利,让其自己负责自己的事件。 举个简单的栗子,这种负责展示头像的视图: 它的职责包括: 通过传入的 URL,加载并展示头像图片 显示一些附属信息,比如大V的标志 将用户点击头像的事件传递给外层的 View Controller 跳转到用户信息页.

学习一定要有针对性的练习-实操! 277

智能合约监控告警:提示工程架构师用AI Prompt实现精准预警

当AI大模型(尤其是代码理解模型如CodeLlama、GPT-4 Code)与区块链数据结合,智能合约监控迎来范式革新。AI模型如何精准理解智能合约的业务特殊性?如何避免"AI幻觉"导致的误报?如何让模型学会区分"正常异常"与"攻击前兆"?答案藏在"提示工程"(Prompt Engineering)中。理解特定智能合约的业务逻辑(如DeFi协议的清算机制、NFT的铸造规则)识别复杂的攻击模式(如重入攻击的调用链特征、闪电贷的套利路径)结合链上链下数据进行多维度推理(如关联价格波动与异常交易)

AI架构全栈开发实战笔记 1010

【Arduino 动手做】构建一个迷你 Las Vegas RGB LED 球体

《Arduino迷你拉斯维加斯球体项目:15岁少年的创意挑战》 15岁的Ben通过本项目展示了如何利用Arduino平台制作一个经济实惠的迷你拉斯维加斯球体夜灯。该项目涉及LED选择(采用WS2812B可编程灯带)、电子元件配置(含Arduino Nano微控制器和红外遥控)以及3D建模设计(100毫米直径球体)。项目难点包括LED布局优化、供电方案设计和3D打印外壳制作。Ben详细记录了从背景研究、电路设计到最终实现的完整过程,特别强调了分辨率与成本的平衡,以及如何通过白色扩散器改善视觉效果。这个项目不仅

雕爷学编程 1022

iOS中self与super

iOS中self与super 一.self关键字 OC语言中的self,就相当于C++、Java中的this指针 1.类方法中的self 在整个程序运行过程中,一个类有且仅有一个类对象。 通过类名调用方法就是给这个类对象发送消息。 类方法的self就是这个类对象 在类方法中可以通过self来调用其他的类方法 不能在类方法中去调用对象方法或成员变量,因为对象方法与成员变量都是属于具体的实例对象的。 2.对象方法中的self 在整个程序运行过程中,对象可以...

box_kun的博客 353

机器人中的数值优化(十二)——带约束优化问题简介、LP线性规划

本系列文章主要是我在学习《数值优化》过程中的一些笔记和相关思考,主要的学习资料是深蓝学院的课程《机器人中的数值优化》和高立编著的《数值最优化方法》等,本系列文章篇数较多,不定期更新,上半部分介绍无约束优化,下半部分介绍带约束的优化,中间会穿插一些路径规划方面的应用实例

慕羽★的博客 3850

[iOS] 关于 self = [super init];

[iOS]关于self=[superinit]; 先看一下官方文档给出的初始化示例代码: [plain] view plaincopyprint? - (id)init { self = [super init]; // Call a designated initializer here. if (self != nil) { // 省略其他细节 } return self; } 容易让人困惑的地方在于,将父类初始化之后,将其返回的对象指针覆盖当前对象的指针。 这种方式令人...

Michae_8l的博客 208

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IOS关于SELF点的一些事情

主要参考文章:http://blog.sina.com.cn/s/blog_a263f0c601010qj9.html 橙色字体为自己标注的的内容,方便加深印象 IPHONE开发SELF的用法 关于什么时间用self. , 其实是和Ob...

chuhuangqiao1461的博客 117

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

iOS Runtime之super与self

所以,你悟了吗?

xinxin_0的博客 444

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

ios开发self和super的区别

self和super区别self 是关键字 代表当前方法的调用者 如果是类方法:代表当前类 如果是对象方法:代表当前类的对象 super编译器指令[self message]和[super message]的实现其实不管是self还是super真正调用的对象都是一样的,只是查找方法的位置不一样,self是在当前类结构中,super是在父类中查找,但方法真正的接受者都是当前类或者当前类的对象[sel

li15809284891的专栏 4183

ios-属性引用self.xx与_xx的区别

在iOS开发过程中,我们用@proprety声明一个属性后,在代码中我们可以用self.xx与_xx来获取到这个属性。但是一直有一个疑惑,那就是这两个之间有什么区别呢?最初我一直觉得这两个之间没什么区别的,直到有一次,我发现自己明明对声明的属性进行了赋值,但是在使用_xx引用时发现为nil,这才引起我的注意。所以,今天在这里对这个问题进行统一的一个说明和学习。 1 @property 与 @sy...

plpldog的博客 758

ios何时使用self.

本文转载至 http://blog.youkuaiyun.com/lvxiangan/article/details/27204265 何时使用self.在网上搜索或者论坛里的回复大多都是简简单单的说这与objc的存取方法有关,如何与存取方式有关究竟他们之间的是什么样的关系就很少有同学回答了。下面以代码来说明问题:创建一个Student类,继承NSObject类,代码:...

a1311010193的博客 143

[iOS] 关于 self = [super init];

先看一下官方文档给出的初始化示例代码: - (id)init { self = [super init]; // Call a designated initializer here. if (self != nil) { // 省略其他细节 } return self; } 容易让人困惑的地方在于,将父类初始化之后,将其返回的对象

苹果君的工作室 1万+

iOS Nav+TabBar下的self.title,self.navigationItem.title,self.tabBarItem.title区别和联系

今天项目中遇到个相当愚蠢的问题,以前没注意到,今天总结下: 大致意思和上面一样,导航栏title和tabBarItem的title不一致。 我的做法是先设置self.tabBarItem.title = @"bb "; 然后self.title = @"MyViewController1"; 结果就是下图: 我查了一些资料: 1.当self.navigationItem.t

huifeidexin_1的专栏 1万+

iOS之self.xxx与_xxx的区别

1.首先通过self.xxx 通过访问的方法的引用:包含了set和get方法。而通过下划线是获取自己的实例变量,不包含set和get的方法。 2.self.xxx 是对属性的访问;而_xxx是对局部变量的访问。所有被声明为属性的成员,再ios5之前需要使用编译指令@synthesize 来告诉编译器帮助生成属性的getter和setter方法,之后这个指令可以不用认为的指定了,默认情况下编译...

plpldog的博客 1053

ios11 中默认开启Self-Sizing

在iOS11,下拉刷新的时候,cell会往上跳动我们知道在iOS8引入Self-Sizing之后,我们可以通过实现estimatedRowHeight相关的属性来展示动态的内容,实现了estimatedRowHeight属性后,得到的初始contensize是个估算值,是通过estimatedRowHeight X cell的个数得到的,并不是最终的contensize,tableview不会一次...

zhangqiaoge的博客 716

iOS学习——属性引用self.xx与_xx的区别

在iOS开发过程中,我们用@proprety声明一个属性后,在代码中我们可以用self.xx与_xx来获取到这个属性。但是一直有一个疑惑,那就是这两个之间有什么区别呢?最初我一直觉得这两个之间没什么区别的,直到有一次,我发现自己明明对声明的属性进行了赋值,但是在使用_xx引用时发现为nil,这才引起我的注意。所以,今天在这里对这个问题进行统一的一个说明和学习。 1@propert...

我爱编程持之以恒 606
上一篇: NSError 错误code对照
下一篇: UITableView多选
yesjava
博客等级 码龄19年 69粉丝 153原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值