小编Mih*_*Oza的帖子

在NSDictionary中获得价值

我希望从中获得价值NSDictionary.我想根据Code键控制"Code"键,我会得到基准值.当我尝试不同的方法时,我收到错误消息.

错误信息

2011-08-11 12:45:21.549 AOK [6312:207] - [__ NSArrayM getObjects:andKeys:]:无法识别的选择器发送到实例0x5e138b0 2011-08-11 12:45:21.550 AOK [6312:207] *终止app由于未捕获的异常'NSInvalidArgumentException',原因:' - [__ NSArrayM getObjects:andKeys:]:无法识别的选择器发送到实例0x5e138b0'*第一次调用时调用堆栈:

的NSDictionary

(
        {
        Omschrijving = "ADDD";
        Ophaaldata =         {
            Datum =             (
                "2011-07-04",
                "2011-07-11",
                "2011-07-18",
                "2011-07-25"
            );
        };
    },
        {
        Omschrijving = "BBBB";
        Ophaaldata =         {
            Datum =             (
                "2011-07-05",
                "2011-07-12",
                "2011-07-19",
                "2011-07-26"
            );
        };
    },
        {
        Omschrijving = "KKKK";
        Ophaaldata =         {
            Datum =             (
                "2011-07-07",
                "2011-07-14",
                "2011-07-21",
                "2011-07-28"
            );
        };
    },
        {
        Omschrijving = "LLLLL";
        Ophaaldata …
Run Code Online (Sandbox Code Playgroud)

objective-c nsdictionary ios

7
推荐指数
1
解决办法
3万
查看次数

UIApplicationDidChangeStatusBarOrientationNotification 已弃用,有其他选择吗?

我已将应用程序目标更改为 IOS 13 以检查应用程序中已弃用的方法,但收到以下警告:

“UIApplicationDidChangeStatusBarOrientationNotification”已弃用:首先在 iOS 13.0 中弃用 - 使用 viewWillTransitionToSize:withTransitionCoordinator: 代替。
这是我在我的项目中实现的代码。

    - (instancetype)init
{
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(onChangeStatusBarOrientationNotification:)
                                                     name:UIApplicationDidChangeStatusBarOrientationNotification
                                                   object:nil];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

请向我建议 ios 12 和 ios 13 的解决方案。

提前致谢。

objective-c nsnotificationcenter ios13 xcode11

7
推荐指数
1
解决办法
3916
查看次数

添加UILabel作为UIButton的子视图不会触发按钮操作

我有一个UIButton,我正在添加一个子视图,UIButton这是一个UILabel.当我点击UILabel按钮的动作时不会被触发.有一个简单的办法,使得触摸事件被传递到UIButton了当UILabel被窃听?
我正在考虑添加一个手势识别器UILabel然后触发它的动作UIButton,不确定是否有更简单的方法.

iphone objective-c ipad ios

6
推荐指数
1
解决办法
6452
查看次数

终止应用程序原因:'AVPlayer实例无法删除由另一个AVPlayer实例添加的时间观察者.

我正在使用Apple的文档演示.以下是demo:AVPlayerDemo的链接

我的应用程序在执行以下步骤后崩溃:
1)
从搜索栏快速播放歌曲2).
3)点击下一步,4)从搜索栏快进.
这是我的崩溃日志:

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因是:'AVPlayer实例无法删除由另一个AVPlayer实例添加的时间观察者.

这是音乐播放器的代码:

- (NSTimeInterval) playableDuration
{
    //  use loadedTimeRanges to compute playableDuration.
    AVPlayerItem * item = player.currentItem;

    if (item.status == AVPlayerItemStatusReadyToPlay) {
        NSArray * timeRangeArray = item.loadedTimeRanges;

        CMTimeRange aTimeRange = [[timeRangeArray objectAtIndex:0] CMTimeRangeValue];

        double startTime = CMTimeGetSeconds(aTimeRange.start);
        double loadedDuration = CMTimeGetSeconds(aTimeRange.duration);

        NSLog(@"get time range, its start is %f seconds, its duration is %f seconds.", startTime/60, loadedDuration/60);
        return (NSTimeInterval)(startTime + loadedDuration);
    }
    else
    {
        return(CMTimeGetSeconds(kCMTimeInvalid));
    }
}  
-(NSTimeInterval)currentItemPlayableDuration{

    //  use loadedTimeRanges to compute …
Run Code Online (Sandbox Code Playgroud)

objective-c seekbar avplayer avplayeritem

6
推荐指数
2
解决办法
3586
查看次数

具有动态按钮列表的类型操作表的UIAlertViewController

作为UIAlertViewUIActionsheet从iOS版8.So过时,建议不要同时使用这两种classes.With老动作片的方法,我可以能够添加标签动态地的for循环的帮助.

UIActionSheet *actionSheet = [[UIActionSheet alloc]init];
actionSheet.title = @"Departure City";
actionSheet.delegate = self;
actionSheet.tag = 1;

for (int j =0 ; j<arrayDepartureList.count; j++)
{
    NSString *titleString = arrayDepartureList[j];
    [actionSheet addButtonWithTitle:titleString];
}
Run Code Online (Sandbox Code Playgroud)

我可以在委托方法中使用按钮索引来执行适当的操作.这样我就可以动态创建动作表.所以在UIAlertController课堂上如何实现这一点,我问这个,因为在UIAlertController课堂上我们必须添加动作处理程序及其动作块.

ios ios8 uialertcontroller

5
推荐指数
2
解决办法
1万
查看次数

从安全分析中收到警告“删除编译器选项 -rpath 以删除 @rpath”

我已经为我的 IOS 应用程序完成了质量扫描分析。我收到以下警告:

The binary has Runpath Search Path (@rpath) set. In certain cases an attacker can abuse this feature to run arbitrary executable for code execution and privilege escalation. Remove the compiler option -rpath to remove @rpath.  
Run Code Online (Sandbox Code Playgroud)

我搜索@rpath并在我的代码pod-framework.sh和下面的代码中找到了:

# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
  if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
    local swift_runtime_libs
    swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) …
Run Code Online (Sandbox Code Playgroud)

cocoapods swift ios14 xcode12

5
推荐指数
1
解决办法
2802
查看次数

在里面找到字典键和字典数组

我有一个包含多个NSMutableDictionary对象的数组.

每次填写文本字段并按下提交按钮:

//The strings
NSString *dateString = @"Date";
NSString *timeString = @"Time";
NSString *typeString = @"Type";

- (IBAction)addData:(id)sender {

[_myDictionary setObject:_dateLabel.text forKey:dateString];
[_myDictionary setObject:_nNumber.text forKey:timeString];
[_myDictionary setObject:_type.text forKey:typeString];

[_myArray addObject:_myDictionary];

[self display]
}
Run Code Online (Sandbox Code Playgroud)

然后我试图在UItextView中显示结果(在这个例子中是日期),但我不知道如何.

    -(void)displayData{

    for (int i = 0; i<_myArray.count; i++) {
        [_myArray objectAtIndex:i];
        outputString = [outputString stringByAppendingFormat:@"%@\n",[_myDictionary objectForKey:@"Date"]];

    }
    _myTextView.text = [NSString stringWithFormat:@"%@",outputString];

}
Run Code Online (Sandbox Code Playgroud)

这最终显示数组中最后一个Dictionary的日期.我甚至无法弄清楚如何从特定的字典中记录日期.
[_myArray objectAtIndex:3] [_myDictionary objectForKey:@"Date"].我如何记录第三个索引的日期?

希望这是有道理的

EDIT SOLUTION

for (int i = 0; i<_myArray.count; i++)
    {

        outputString = [outputString stringByAppendingFormat:@"%@ …
Run Code Online (Sandbox Code Playgroud)

nsmutablearray nsmutabledictionary ios

3
推荐指数
1
解决办法
1万
查看次数

如何在iOS中获取当年的开始日期

我不知道如何使用NSDateNSCalendar在这种情况下.
帮我解决这个问题.

objective-c nsdate nscalendar ios

3
推荐指数
2
解决办法
4361
查看次数

Swift 2.0错误来自'[NSIndexPath]?' 到'[indexpath]'只能解包可选

嗨下面的代码在swift1.2中工作正常,但当我升级到swift 2.0时:

func deselectAllRows() {
    if let selectedRows = tableView.indexPathsForSelectedRows as! [NSIndexPath] {
        for indexPath in selectedRows {
            tableView.deselectRowAtIndexPath(indexPath, animated: false)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它显示以下错误:

来自'[NSIndexPath]?' 到'[indexpath]'只能解包可选

有关如何解决此问题的任何线索?

uitableview ios swift swift2

3
推荐指数
1
解决办法
900
查看次数

使用Google Maps SDK for IOS时Apple Mach-O Linker出错

我正在尝试在我的应用中使用Google Maps SDK.到目前为止,我已经链接了所有框架.我很确定我-ObjC按照说明添加了适当的标志.但是,当我将代码复制并粘贴到我的ViewController.m类中时,我收到以下错误:

架构i386的未定义符号:
"_ OBJC_CLASS _ $ _ GMSCameraPosition",引用自:FoothillTourViewController.o中的objc-class-ref"_OBJC_CLASS _ $ _ GMSMapView",引自:FoothillTourViewController.o中的objc-class-ref"_OBJC_CLASS _ $ _ GMSMarker",引用自:FoothillTourViewController.o中的objc-class-ref"_OBJC_CLASS _ $ _ GMSServices",引自:FoothillTourAppDelegate.o中的objc-class-ref:ld:未找到架构i386 clang的符号:错误:链接器命令失败,退出代码为1 (使用-v查看调用)

"FoothillTourViewController"是我ViewController班级的名字.这是我的View Controller类的代码.代码直接取自说明.

#import "FoothillTourViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@implementation FoothillTourViewController {
    GMSMapView *mapView_;
}

// You don't need to modify the default initWithNibName:bundle: method.

  - (void)loadView {
  //Create a GMSCameraPosition that tells the map to display the
  // coordinate -33.86,151.20 at zoom level 6.
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios

2
推荐指数
1
解决办法
5311
查看次数