gpt4 book ai didi

ios - 如何在其他类 objective-c 中获取循环值

转载 作者:行者123 更新时间:2023-12-01 18:49:57 25 4
gpt4 key购买 nike

我在bezier.m中有此代码

for(int x = 0; x < [globalArray count]; ++x){
NSInteger numOfCurves = [globalArray[x] count];
UIBezierPath *linesegment = [UIBezierPath bezierPath];
for(int y=0; y< numOfCurves; y++){
[UIBezierPath makeControlPoints:globalArray[x]];
[UIBezierPath makeAnchorPoints:globalArray[x]];
linesegment = [UIBezierPath makeTheCurve:globalArray[x]];
}

strPaths = [NSString stringWithFormat:@"%@", linesegment];
NSLog(@"log %@", strPaths);

linesegment.lineWidth = [[self.linesWidth objectAtIndex:x] floatValue];
[[UIColor blackColor] setStroke];
linesegment.lineCapStyle = kCGLineCapRound;
[linesegment stroke];
}

我需要将“strPaths”的值传递到viewcontroller.m,其输出如下
  log <UIBezierPath: 0x7fd50147ff30; <MoveTo {201, 130.5}>,
<CurveTo {167.25000023841858, 130.6666666418314} {188.66666698455811, 130.33333332836628} {176.33333396911621, 130.16666665673256}>,
<CurveTo {145.83333325386047, 134.75} {158.16666650772095, 131.16666662693024} {152.33333301544189, 132.33333325386047}>,
<CurveTo {129.25000017881393, 146} {139.33333349227905, 137.16666674613953}

log <UIBezierPath: 0x7fd50147ff30; <MoveTo {201, 130.5}>,
<CurveTo {167.25000023841858, 130.6666666418314} {188.66666698455811, 130.33333332836628} {176.33333396911621, 130.16666665673256}>,
<CurveTo {145.83333325386047, 134.75} {158.16666650772095, 131.16666662693024} {152.33333301544189, 132.33333325386047}>,
<CurveTo {129.25000017881393, 146} {139.33333349227905, 137.16666674613953}

等等....

最佳答案

您可以使用NSUserDefaults如下存储值

[[NSUserDefaults standardUserDefaults]setValue:strPaths forKey:@"strPaths"];

并按如下所示检索该数据
[[NSUserDefaults standardUserDefaults] valueForKey:@"strPaths"];

希望这可以帮助..

关于ios - 如何在其他类 objective-c 中获取循环值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31913342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com