swift中的指针问题

时间:2015-10-24 08:27:40

标签: ios swift

有时在这行代码中 let p:PingViewCell = PingViewCell() 我收到此错误

  

malloc:***对象0x7fd0724bd050的错误:被释放的指针是   未分配

有人可以解释一下它是什么意思:这是我的PingViewCell类

class PingViewCell: UITableViewCell {

@IBOutlet var TimeLabel: UILabel!
@IBOutlet var NavigationButton: UIButton!

@IBOutlet var listenCount: UILabel!

@IBOutlet var BingsCount: UILabel!
@IBOutlet var pingDuration: UILabel!
@IBOutlet var PlayButton: UIButton!
@IBOutlet var slider: UISlider!

var PlayButtonState:Bool=false
var SliderCurrentValue:Float=0.0

var FavoriteButtonState=false
var bingCount=0
var Pingpath=""
var PingID=""
var Duration=0
var Date=""
var ReceiversCount=0
var currentDuration=0
var pingData:NSData?


override func awakeFromNib() {
    super.awakeFromNib()


    var image = UIImage(named: "thumb.png")
    slider.setThumbImage(imageWith(image!, scaledToSize: CGSize(width: 10, height: 10)), forState: UIControlState.Normal)
}

func imageWith(image : UIImage, scaledToSize:CGSize ) -> UIImage {
    UIGraphicsBeginImageContextWithOptions(scaledToSize, false, 0.0);
    image.drawInRect(CGRectMake(0, 0, scaledToSize.width, scaledToSize.height))
    let newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}


override func setSelected(selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

} ///更新

 if  anyObj is Array<AnyObject> {

            for json in anyObj as! Array<AnyObject>{

               let p:PingViewCell = PingViewCell()

                p.PingID = (json["PingID"] as? String)!
                p.Date = getDateFromString((json["Date"] as? String)!)!
                p.Duration = (json["Duration"] as AnyObject? as? Int)!
                p.Pingpath = (json["PingPath"] as AnyObject? as? String)!
                p.ReceiversCount = (json["ReceiversCount"] as AnyObject? as? Int)!
                p.bingCount = (json["bingsCount"] as AnyObject? as? Int)!
                p.currentDuration=p.Duration
                Data.PingList.append(p)
            }
        }

0 个答案:

没有答案