小编Sam*_*amG的帖子

Swift项目与线程1崩溃:EXC_BAD_ACCESS(代码= 1,地址= 0x0)

它看起来像是一个糟糕的内存访问,就像尝试访问不存在的对象一样.我尝试使用NSZombie看看是否有什么东西出现,据我所知,没有做到.它在app委托的声明中崩溃了.

AppDelegate.swift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool
{
    // Override point for customization after app launches
    Parse.setApplicationId("removed on purpose", clientKey: "removed on purpose")
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
    PFFacebookUtils.initializeFacebook()

    return true
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool
{
    return FBAppCall.handleOpenURL(url, sourceApplication: sourceApplication, withSession: PFFacebookUtils.session())

}

func applicationDidBecomeActive(application: UIApplication)
{
    FBAppCall.handleDidBecomeActiveWithSession(PFFacebookUtils.session())
}

func applicationWillResignActive(application: UIApplication)
{
    // Sent when the application is about to …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

UIImageView在自定义UICollectionViewCell中返回nil

上周我问了一个类似的问题,但我想我已经把它缩小到更具体的问题.正在加载自定义单元格,并且当我使用collectionView.dequeReusableCellWithIdentifier("MenuCell", forIndexPath: indexPath) as MenuCollectionViewCell"MenuCell" 时,看起来正确调用我的自定义单元格的重用标识符,而MenuCollectionViewCell是保存自定义代码的swift文件.从调试代码我已经确定没有加载UIImageView.我做了一张支票,这就是我想出来的.为什么没有加载ImageView并且只显示为nil我不知道.我将发布加载它的文件的代码和自定义单元代码.

class MenuViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate
{
    // Not sure if I really need this
    @IBOutlet var menuCollectionView: MenuCollectionView!

    override func viewDidLoad()
    {
        super.viewDidLoad()
        // Do any additional setup after loading the view
        view.backgroundColor = UIColor(patternImage: UIImage(contentsOfFile: "behind_alert_view.png"))
        // This was the fix here
        self.menuCollectionView.delegate = self
        self.menuCollectionView.dataSource = self

    }

    // Variables
    var menuImagesArray = ["MyProfileIcon.png"]

    // Data Source Protocol
   func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int
    {
        return 1
    }

    func collectionView(collectionView: UICollectionView, …
Run Code Online (Sandbox Code Playgroud)

uiimageview ios swift

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

试图检查PFFile是否有数据

我试图在尝试从后台拉出图像之前检查PFFile是否有数据.我正在尝试这个,因为如果你试图打开其中一个物体并且没有图像,我会继续致命的崩溃!我的问题是我无法使数据检查工作.因为PFFile不符合布尔协议PFFile != nil,if (recipeImageData)所以无法检查它是否存在.任何帮助,将不胜感激!

这是变量的声明:

var recipeImageData: PFFile = PFFile()
Run Code Online (Sandbox Code Playgroud)

这是获取数据的功能:

override func viewWillAppear(animated: Bool) {
  navItem.title = recipeObject["Name"] as? String
  recipeImageData = recipeObject["Image"] as PFFile //Fatally crashes on this line
  // Fetch the image from the background
  if (recipeImageData) {
    recipeImageData.getDataInBackgroundWithBlock({
      (imageData: NSData!, error: NSError!) -> Void in
      if error == nil {
        self.recipeImage.image = UIImage(data: imageData)?
      } else {
        println("Error: \(error.description)")
      }
    })
  }
}
Run Code Online (Sandbox Code Playgroud)

编辑:

我只是试着看到我可能正在检查错误的区域.这是我更新的代码.

override func viewWillAppear(animated: Bool) {
  navItem.title = …
Run Code Online (Sandbox Code Playgroud)

ios parse-platform pffile

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

标签 统计

ios ×3

swift ×2

parse-platform ×1

pffile ×1

uiimageview ×1