objectAtIndex:

本文介绍了一种通过指针操作来直接修改容器中元素的方法。使用这种方法时, 对指针所指向的对象进行的任何更改都会反映到容器中的相应元素上。

dict = [ _mutableArray objectAtIndex:indexPath.row ];

 

返回 的存储在容器中的指针,修改dict会影响到容器中的数值。

分析下面代码有无实现ip为2001::1的逻辑 // // SDNV6LanDhcpHelper.m // Omada // // Created by zzp on 2025/7/11. // Copyright © 2025 TP-Link. All rights reserved. // #import "SDNV6LanDhcpHelper.h" #import "TPSDNControllerCommonMethod.h" #import "TPIPv6Calculator.h" @implementation SDNV6LanDhcpHelper - (void)updateWithGateway:(NSString *)gateway andCount:(NSString *)count { NSArray<NSString *> *iparr = [gateway componentsSeparatedByString:@"."]; NSMutableString *ipstr = [[NSMutableString alloc]init]; for (int i = 0; i<4; i++) { [ipstr appendString:[TPSDNControllerCommonMethod toBinarySystemWithDecimalSystem:iparr[i]]]; } NSString *ipmin = [ipstr copy]; NSString *ipmax = [ipstr copy]; NSString *subnetMask = [ipstr copy]; for (int i = [count intValue]; i<ipmin.length; i++) { ipmin = [ipmin stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:@"0"]; } for (int i = [count intValue]; i<ipmax.length; i++) { ipmax = [ipmax stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:@"1"]; } for (int i = 0; i<[count intValue]; i++) { subnetMask = [subnetMask stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:@"1"]; } for (int i = [count intValue]; i<ipmax.length; i++) { subnetMask = [subnetMask stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:@"0"]; } NSString *ipminrange = [ipmin stringByReplacingCharactersInRange:NSMakeRange(ipmin.length-1, 1) withString:@"1"]; NSString *ipmaxrange = [ipmax stringByReplacingCharactersInRange:NSMakeRange(ipmax.length-1, 1) withString:@"0"]; NSMutableArray<NSString *> *broadCastList = [[NSMutableArray alloc]init]; NSMutableArray<NSString *> *iparrmin = [[NSMutableArray alloc]init]; NSMutableArray<NSString *> *iparrmax = [[NSMutableArray alloc]init]; NSMutableArray<NSString *> *subnetMaskList = [[NSMutableArray alloc]init]; NSString *broadCast = [NSString new]; NSString *rangeLeft = [[NSString alloc]init]; NSString *rangeRight = [[NSString alloc]init]; NSString *subnet = [[NSString alloc]init]; for (int i = 0; i<4; i++) { [iparrmax addObject:[TPSDNControllerCommonMethod toDecimalSystemWithBinarySystem:[ipmaxrange substringWithRange:NSMakeRange(i*8, 8)]]]; [iparrmin addObject:[TPSDNControllerCommonMethod toDecimalSystemWithBinarySystem:[ipminrange substringWithRange:NSMakeRange(i*8, 8)]]]; [broadCastList addObject:[TPSDNControllerCommonMethod toDecimalSystemWithBinarySystem:[ipmax substringWithRange:NSMakeRange(i*8, 8)]]]; [subnetMaskList addObject:[TPSDNControllerCommonMethod toDecimalSystemWithBinarySystem:[subnetMask substringWithRange:NSMakeRange(i*8, 8)]]]; broadCast = [broadCast stringByAppendingString:[broadCastList objectAtIndex:i]]; rangeLeft = [rangeLeft stringByAppendingString:[iparrmin objectAtIndex:i]]; rangeRight = [rangeRight stringByAppendingString:[iparrmax objectAtIndex:i]]; subnet = [subnet stringByAppendingString:[subnetMaskList objectAtIndex:i]]; if (i<3) { broadCast = [broadCast stringByAppendingString:@"."]; rangeLeft = [rangeLeft stringByAppendingString:@"."]; rangeRight = [rangeRight stringByAppendingString:@"."]; subnet = [subnet stringByAppendingString:@"."]; } } double Ipv4Count =pow(2, 32-[count intValue])-2; self.gateway = gateway; self.broadCast = broadCast; self.count = [NSString stringWithFormat:@"%0.f",Ipv4Count]; self.range = [NSString stringWithFormat:@"%@ - %@",rangeLeft,rangeRight]; self.subnetMask = subnet; self.suggestRangeStart = rangeLeft; self.suggestrangeEnd = rangeRight; } - (void)updateWithIpv6Gateway:(NSString *)gateway andCount:(NSString *)count { TPIPv6Calculator *ipv6Calculator = [[TPIPv6Calculator alloc] initWithAddress:gateway prefix:count]; ipv6Calculator.dhcpRangeCount = 2000; self.gateway = ipv6Calculator.gatewayIpv6Str; self.broadCast = ipv6Calculator.ipv6Address; self.count = ipv6Calculator.ipv6Count; self.range = ipv6Calculator.ipv6Range; self.suggestRangeStart = ipv6Calculator.dhcpStartStr; self.suggestrangeEnd = ipv6Calculator.dhcpEndStr; } @end
最新发布
12-09
学习以下用法:压缩图片 property level : “best” on run compress() end run on compress() do shell script "sips -s format jpeg -s formatOptions " & level & " /Users/sunsjay/Desktop/a.png --out /Users/sunsjay/Desktop/output.png " end compress A老师想从网络文件夹1和网络文件夹2查找B学生提交的作业,并复制到本地桌面查看。 set jobNumber to “a” tell application “Finder” set fileOne to “COMMON:sunsjay🅰️” & jobNumber & “.txt” set fileTwo to “COMMON:sunsjay🅱️” & jobNumber & “.txt” if (exists file fileOne) then duplicate file fileOne to desktop display dialog “已经从a文件夹找到,并复制到桌面” else if (exists file fileTwo) then duplicate file fileTwo to desktop display dialog “已经从b文件夹找到,并复制到桌面” else display dialog “文件没有找到” end if end tell 查看我电脑里已经安装的软件是什么,以及对应的版本。将它们生成txt文档并放在桌面 use AppleScript version “2.5” use framework “Foundation” use scripting additions set plistString to do shell script “system_profiler -xml SPApplicationsDataType” set dataString to current application’s NSString’s stringWithString:plistString set plistData to dataString’s dataUsingEncoding:4 set propertyList to current application’s NSPropertyListSerialization’s propertyListWithData:plistData options:0 format:(missing value) |error|:(missing value) set allItems to (propertyList’s objectAtIndex:0)'s objectForKey:“_items” set nameAndVersion to allItems’s dictionaryWithValuesForKeys:{“_name”, “version”, “path”} set appList to (nameAndVersion’s objectForKey:“_name”) as list set appVersionList to (nameAndVersion’s objectForKey:“version”) as list set appPathList to (nameAndVersion’s objectForKey:“path”) as list set dateStamp to (do shell script “date "+%Y-%m-%d-%H-%M"”) set desktopPath to (path to desktop as text) – List set myList to {“All Installed Apps”, “Avoid Apple Apps”} set chosenItem to choose from list myList with prompt “Options” if chosenItem is false then display dialog “请选择.” else if chosenItem’s first item = “All Installed Apps” then set theFilePath to desktopPath & "All Installed Apps " & dateStamp & ".txt" set theFile to open for access theFilePath with write permission repeat with i from 1 to count of appList set appName to item i of appList set appVersion to item i of appVersionList log appName & " " & appVersion write (appName & " " & appVersion & return) to theFile starting at eof end repeat close access theFile display dialog "All installed apps saved to Desktop" else if chosenItem's first item = "Avoid Apple Apps" then set theFilePath to desktopPath & "All Installed Apps without Apple Apps " & dateStamp & ".txt" set theFile to (open for access theFilePath with write permission) repeat with i from 1 to count of appList set appName to item i of appList set appVersion to item i of appVersionList set appPath to item i of appPathList set bundleID to do shell script "mdls -name kMDItemCFBundleIdentifier -r \"" & appPath & "\"" if bundleID does not start with "com.apple." then -- Exclude com.apple. bundle IDs log appName & " " & appVersion & " " & bundleID write (appName & " " & appVersion & return) to theFile starting at eof end if end repeat close access theFile display dialog "Avoided System Apps and saved to Desktop" end if end if
08-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值