TEL:400-8793-956
当前位置:程序、服务器

运行应用程序时收到致命错误“致命错误-数组索引超出范围”

提问者: 近期获赞: 浏览人数: 发布时间:2021-02-22 09:26:30

 问:我的“构建播放列表浏览器”应用程序代码与项目文件中的源代码相同。但是我在运行时收到错误消息。我可以成功构建该应用程序,但是在加载之前运行时它将崩溃。

 
import  Foundation 
import  UIKit 
struct播放列表{ var title :String ?var描述:字符串?var图标:UIImage ?var largeIcon :UIImage吗?var artists :[ String ] = [] var backgroundColor :UIColor = UIColor 。clearColor ()init (index :Int )
 
      {
让musicLibrary = MusicLibrary ()。库let playlistDictionary = musicLibrary [ index ] //在此行上引发错误title = playlistDictionary [ “ title” ]为!弦!description = playlistDictionary [ “ description” ]为!弦!让iconName = playlistDictionary [ “ icon” ]为!弦!      
        icon  =  UIImage (名为: iconName )
让largeIconName = playlistDictionary [ “ largeIcon” ]为!弦!largeIcon =的UIImage (名为:largeIconName )艺术家+ = playlistDictionary [ “艺术家” ]作为![ String ]让colorsDictionary = playlistDictionary [ “ backgroundColor” ]为![
 
             字符串:CGFloat ] 
backgroundColor = rgbColorFromDictionary (colorsDictionary )}              
 
 
答:创建新的时会发生崩溃Playlist。您正在传递init一个MusicLibrary().library没有的值。如果您可以发布应用程序的其余代码,那么我也许可以帮助您找出原因
上一篇: 访问数组中的对象有些不同?
下一篇: PHP OOP中的类vs对象vs实例