iOS - self & super 理解的关键点

YOLOv8与注意力机制融合:EMA(高效多维注意力)的原理剖析与实战应用 本文介绍了如何在YOLOv8目标检测模型中集成EMA(高效多尺度注意力)机制。主要内容包括:EMA注意力机制的工作原理解析,展示其多尺度特征融合和高效计算特性;详细的环境配置与依赖安装指南;EMA模块的完整代码实现,包含分组处理、空间注意力权重计算和特征融合等关键步骤;以及将EMA集成到YOLOv8网络结构的方法。通过添加EMA模块,可以提升模型对关键特征的关注能力,有效抑制背景干扰,从而增强目标检测性能。本教程提供了从原理到实现的完整解决方案。 阅读详情

1. method 搜寻路径

(在运行时,调用的到底是哪个 setOrigin::)

- reposition
{
 ...
 [self setOrigin:someX :someY];
 ...
}
或者:

- reposition
{
 ...
 [super setOrigin:someX :someY];
 ...
}

规则:

系统在解析 self 的时候,跟继承链没关系,哪个对象收到消息,self就指的是哪个对象,也就是运行时确定 self 到底指的是谁;
系统在解析 super 的时候,似乎是编译时就定死了,就看 super 是在哪个类方法里出现的,然后调用其父类(或者沿着继承链向上追溯)的该方法,跟消息的接收者没关系。


2. self 在不同语境下有不同含义:

Inside an instance method, self refers to the instance; but inside a class method, self refers to the class object. 

This is an example of what not to do:

+ (Rectangle *)rectangleOfColor:(NSColor *) color
{
 self = [[Rectangle alloc] init]; // BAD
 [self setColor:color];
 return [self autorelease];
}

To avoid confusion, it’s usually better to use a variable other than self to refer to an instance inside a class

method:

+ (id)rectangleOfColor:(NSColor *)color
{
 id newInstance = [[Rectangle alloc] init]; // GOOD
 [newInstance setColor:color];
 return [newInstance autorelease];
}

In fact, rather than sending the alloc message to the class in a class method, it’s often better to send alloc
to self. This way, if the class is subclassed, and the rectangleOfColor: message is received by a subclass,
the instance returned is the same type as the subclass(for example, the array method of NSArray is inherited

by NSMutableArray).

+ (id)rectangleOfColor:(NSColor *)color
{
 id newInstance = [[self alloc] init]; // EXCELLENT
 [newInstance setColor:color];
 return [newInstance autorelease];
}

这些是从apple官方文档里摘录的,英文很简单,再配合例子,就没必要翻译了。


yolov5改进之Fasternet主干网络替换 fasternet替换yolov5主干网络 阅读详情

相关推荐

逆向实战:手把手教你用Frida绕过Flutter App的SSL Pinning(附脚本修改指南)

本文详细介绍了如何利用Frida工具绕过Flutter应用的SSL Pinning保护机制,包括静态分析定位关键函数、定制Frida Hook脚本以及流量捕获的完整解决方案。通过实战案例和脚本修改指南,帮助安全研究人员有效应对Flutter应用的安全挑战,特别适用于安卓平台的逆向工程和抓包需求。

weixin_28723171的博客 402

iOS 中self和super如何理解?

或许你理解self和super都是指的是类的对象 self指的是本类的对象,而super指的是父类的对象,但是事实情况呢,可能有些和你想象的不一样? 简单看下下面例子: @interface Person:NSObject { NSString* name; } - (void) setName:(NSString*) yourName; @end @...

dixiannie4307的博客 304

【仿真】Carla Python API实战:从零搭建自动驾驶测试环境

本文详细介绍了如何使用Carla Python API从零搭建自动驾驶测试环境。通过Carla仿真平台,开发者可以构建高度逼真的城市环境和车辆物理模型,利用Python API实现传感器配置、数据采集、场景构建及自动驾驶算法集成。文章还分享了实际项目中的调试技巧和性能优化经验,帮助读者快速掌握自动驾驶仿真测试的核心技术。

weixin_29050513的博客 213

IOS Super的理解

IOS Super的理解 @implementation Son : Father - (id)init { self = [super init]; if (self) { NSLog(@”%@”, NSStringFromClass([self class]));

Erice_e的专栏 2299

工业相机图像格式深度解析:从Mono8到Mono12的选型与应用

本文深度解析工业相机黑白图像格式,重点对比Mono8、Mono10与Mono12的核心差异。文章从位深、动态范围和数据量等关键概念切入,详细阐述了不同格式的优缺点及适用场景,为工业视觉项目中的相机选型提供实战指南,帮助用户在精度、速度与成本间做出最优决策。

weixin_29207439的博客 260

Aruba CX交换机VSX配置实战:如何避免脑裂导致的网络中断(含详细命令)

本文提供Aruba CX交换机VSX配置的实战指南,重点讲解如何通过构建高可靠的ISL链路聚合与独立隔离的Keepalive链路,有效避免网络脑裂风险。文章包含详细的命令步骤,从基础配置到高级故障排查,帮助网络工程师构建坚如磐石的高可用核心网络,确保业务流量零中断。

weixin_29231725的博客 170

iOS self和super的区别

self和super的区别 #import <Foundation/Foundation.h> 首先先写两个类 fist和two,two继承fist类 @interface First:NSObject { int a;//声明了一个变量 } -(void) setA:(int)c;//对a赋值的方法 @end @implementation Fir...

101

华为OD技术面真题 - 数据库Mysql - 1

汇总华为OD技术面高频Mysql相同问题,提供详细解答。

qq_45776114的博客 1083

iOS self 和 super 学习

有人问我 这个问题 回答错了,题干大概是说 [self class] 和 [super class]打印结果 是不是一样的. 我睁着眼睛说是不一样的 .因为我明明记得 几天前 做 DFS 获取反射基类 用到了这块 然 pia pia 打脸 运行一遍 先印证答案: 在 AppDelegate 里面: NSLog(@" %@ %@ %@",[self class],[super c...

weixin_34009794的博客 490

三维空间刚体运动4-3:四元数线性插值方法:Squad

摘要:四元数插值三个方法Slerp、Squad和Spring既复杂又很重要,为了详细阐述,故每个方法独立成一篇博文讲解,没有插值的四元数是没有灵魂的,插值的重要性不言而喻。Slerp是经典的两点间一阶连续可导插值方法,Squad方法在Slerp的基础上实现多点间的一阶连续可导,而Spring则可以实现多点间的二阶连续可导,更适合复杂的曲线,此系列博文也是国内首篇介绍Spring的中文资料。

shao918516的博客 9217

企业级托管钱包架构设计与MPC密钥管理:基于Go语言的生产级实践

本文探讨了2026年Web3生态中企业级托管钱包的技术架构与实现方案。文章指出,传统私钥管理模式已无法满足机构级资产管理需求,而基于多方安全计算(MPC)和门限签名(TSS)的技术方案成为主流选择。研究分析了托管钱包的四层架构设计,详细解读了MPC的核心技术原理,包括分布式密钥生成(DKG)和签名协议演进。通过Go语言实现案例,展示了密钥分片管理、DKG流程和交易签名等核心模块的代码实现。文章还提出了生产部署的安全原则、容灾设计和监控体系,并讨论了密钥撤销等现存挑战及TEE融合等未来趋势。研究为构建安全、高

分享AI、区块链技术及应用,未来已来 81

iOS中self与super详解(转)

原文:http://blog.sina.com.cn/s/blog_702e40a80101d34z.html 原文:http://www.jianshu.com/p/9027506a2f73 在 Objective-C 中的类实现中经常看到这两个关键字 ”self” 和 ”super”,以以前 oop 语言的经验,拿 c++ 为例,self 相当于 this,super 相当于调用...

argyjotg330046的博客 159

L2tp环境搭建笔记- Openwrt平台

本文使用3台openwrt设备, 分别搭建L2TP服务和2个客户端, 进行端到端验证和局域网组网,并分析搭建过程中涉及的默认路由( defaultroute) 配置问题。

十年通信老兵的技术修炼之路——从3G到5G,从地面基站到卫星通信。 3389

iOS开发视图控制器(ViewController)调用[super viewXXX]的简单理解

iOS开发视图控制器(ViewController)调用[super viewXXX]的简单理解本人刚刚进入iOS开发行业,许多理解可能存在错误,希望各位老司机看到能够指出。那么言归正传,记得在学习iOS开发的时候,老师讲过,- (void)viewDidLoad 、这类的函数中,要先调用父类的方法即:[super viewDidLoad]来完成一些事情,那么这些方法究竟做了什么呢?于是我就创建了多

Cold_of_22F的博客 3293

深度学习工具包 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")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Objective-C中的self和super理解

@implementation xxx : NSObject - (id)init { self = [super init]; if (self) { } return self; } 1、self是一个隐藏参数变量 self是一个隐藏参数变量,指向当前调用方法的对象,还有一个隐藏参数是_cmd,代表当前方法selector。在runtime时会调用objc_...

Pandakingli的博客 350

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

iOS Runtime面试题([self class] 与 [super class])

[self class] 与 [super class] 下面的代码输出什么? @implementation Son : Father - (id)init { self = [super init]; if (self) { NSLog(@"%@", NSStringFromClass([self class])); ...

小丑鱼 725

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

黑马程序员-ios学习笔记:self,super

------------- java培训、android培训、java博客、java学习型技术博客、期待与您交流! --------------

li1225136753的专栏 433

iOS经典讲解之[self class]和[super class]的区别

作者:Loving_iOS 转载请标明出处: 在objc中的类实现中经常看到这两个关键字”self”和”super”,但他们的区别表现在各个方面。 以下面的代码为例: @interface Father:NSObject { NSString* name; } - (void)setName:(NSString*) yourName; @end @interfac

刘新林的技术博客 8491

iOS self 和super原理详解

self 和 super 1. self调用自己方法,super调用父类方法 2. self是类,super是预编译指令 3. [self class]和[super class]输出是一样的self和super底层实现原理: 1、当使用 self 调用方法时,会从当前类的方法列表中开始找,如果没有,就从父类中再找;而当使用 super 时,则从父类的方法列表中开始找,然后调用父类的这

Mr_XiaoJie的博客 720

iOS:Objective-C中Self和Super详解

Objective-C 中Self 和 Super 详解本文要介绍的内容,在 Objective-C 中的类实现中经常看到这两个关键字 self 和 super,以以前 oop 语言的经验,拿 c++ 为例,self 相当于 this,super 相当于调用父类的方法,这么看起来是很容易理解的。   在 Objective-C 中的类实现中经常看到这两个关键字 ”self” 和 ”super

taylor的专栏 1万+

self与super 怎么理解?

二者都是根据当前环境但区别是: super:直接跳过本级向上级逐层查找方法 self:从本级向上级逐层查找 例如: 父类:Person -(void)eat{ NSLog(@“人开始吃饭”); } 子类:Student -(void)eat{ NSLog(@“学生开始吃饭”); } (void)bothEa

Ios为我所用 695

iOS self = [super init]

self = [super init] 这个问题一直不太明白,今天研究了一下,在stackoverflow找到了下面的答案: http://stackoverflow.com/questions/2956943/why-should-i-call-self-super-init 我对这些答案简单翻译总结下: 要明白这个问题,首先要知道self 是什么东西,我们什么时候会用到self。 se...

weixin_30262255的博客 166

黑马程序员---iOS基础---OC中的self、super

------Java培训、Android培训、iOS培训、.Net培训、期待与您交流! ------- 1.self和super OC提供了两个保留字self和super,用于在方法定义中引用执行该方法的对象。 OC语言中的self,就相当于C++、Java中的this指针。 学会使用self,首先要搞清楚属性这一概念。 设置器与访问器,提供外界操作类内部属性的一个通道。

wodepei的博客 613
上一篇: iOS - apple官方ARC文档关键点摘录
下一篇: iOS - id && Object Messaging 深入讲解
object_c_key
博客等级 码龄11年 0粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值