onSaveInstanceState()保存数值

需要在onSaveInstanceState()中保存数组列表的值,数值是来自onCreat方法的数组。但是系统运行后报错。

public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putParcelable("Old", (Parcelable) profileDetails );
    super.onSaveInstanceState(savedInstanceState);
}

在onCreate()

if (savedInstanceState != null) { 
    profileDetails= (ArrayList<ProfileDetails>)savedInstanceState.getParcelable("Old");
}
else {
    profileDetails = GetSearchResults();
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addAnimation:) name:UIApplicationWillEnterForegroundNotification object:nil];

}

- (void)addAnimation:(NSNotification *)notificaiton
 {
 CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
 animation.fromValue = [NSNumber numberWithFloat: 2*M_PI];
 animation.toValue = [NSNumber numberWithFloat:0.0f];
 animation.duration = 4.0f;
 animation.repeatCount = INFINITY;
 [imageLeft.layer addAnimation:animation forKey:@"SpinAnimation"];
 [imageRight.layer addAnimation:animation forKey:@"SpinAnimation"];
 }

profileDetails 这个东西没有实现Parcelable接口