我有一個包含變量稱爲currentBusiness不能FullFill一個故障錯誤,可能是ARC相關
我連線的currentBusiness財產這樣
-(Business *) currentBusiness
{
if ([[NSThread currentThread] isMainThread])
{
DLog(@"I am a main thread");
}
else
{
assert (false);
DLog(@"I am not a main thread");
}
CLog(@"_currentBusiness %@ withObjectID: %@", _currentBusiness, _currentBusiness.objectID);
if (IsEmpty(_currentBusiness))
{
//assert(false);
}
if (_currentBusiness.isFault)
{
assert(false); //This is reached
}
return _currentBusiness;
}
另外,我把一個類別的商業捕獲單會轉彎故障
- (void)willTurnIntoFault
{
if ([[NSThread currentThread] isMainThread])
{
CLog(@"Faulting: %@", self); //called sometimes and during time of interest never called
if (self == [BNUtilitiesQuick currentBusiness])
{
CLog(@"Current Business is Faulting");//never called
}
}
[super willTurnIntoFault];
}
所以,一切都很好。如預期的那樣[BNUtilities currentBusiness]向視圖控制器提供必要的信息。然而,隨機(儘管幾乎肯定)的位置,如果我改變看法,說我想激活呼叫(用簡單的代碼)。突然
if (_currentBusiness.isFault)
{
assert(false); //This is reached
}
我絕對沒有什麼可以改變_currentBusiness。底層的業務不會被刪除。
我也把上絆索
-(void) setCurrentBusiness:(Business *)currentBusiness
{
if ([[NSThread currentThread] isMainThread])
{
DLog(@"I am a main thread");
}
else
{
assert (false);
DLog(@"I am not a main thread");
}
_currentBusiness = currentBusiness;
}
,並注意它沒有達到。所以_currentBusiness,憑空突然變成故障
這是_currentBusiness
2012-05-21 15:42:24.952 BadgerNew[2292:17003] <0x87909a0 UtilitiesQuick.m:(69)> _currentBusiness <Business: 0x96a8980> (entity: Business; id: 0x9683b30 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15> ; data: {
Aliases = "<relationship fault: 0x96b8540 'Aliases'>";
Bookmark = 0;
Building = "0x9683b30 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15>";
City = "0x9694880 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/City/p2>";
Distance = "689.0068307560858";
DistanceGrouping = "0x96b9b90 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/DistanceGrouping/p890>";
Districts = (
"0x92a6450 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/District/p4>"
);
Email = nil;
ID = "universitas-indonusa-esa-unggul__-6.19_106.78";
Images = (
"0x93edb50 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Image/p20>"
);
InBuildingAddress = nil;
LatitudeLongitude = "0x96bd6a0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/LatitudeLongitude/p15>";
Like = 0;
OpeningHour = nil;
PeopleCount = 295;
Phones = (
"0x92dcbf0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Phone/p4>"
);
Price = 0;
Promotions = "<relationship fault: 0x9693480 'Promotions'>";
Rating = "0x96a0f00 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Rating/p15>";
RatingGroup = "0x9682bd0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/RatingGroup/p15>";
Reviews = (
);
Street = "Jl. Arjuna Utara";
Tags = (
"0x92b5c10 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Tag/p12>"
);
Tenants = "<relationship fault: 0x96e6fd0 'Tenants'>";
TimeStamp = nil;
Title = "Universitas Indonusa Esa Unggul";
URLs = "<relationship fault: 0x968d930 'URLs'>";
Website = nil;
Zip = 11510;
checkIn = nil;
pinAndLineNumber = 2;
timeLike = nil;
updated = 1;
})
「正常」 的內容時,它就會發生故障,在
if (_currentBusiness.isFault)
{
assert(false); //This is reached
}
這突破是結果:
2012-05-21 15:42:36.782 BadgerNew[2292:17003] <0x87909a0 UtilitiesQuick.m:(69)> _currentBusiness <Business: 0x96a8980> (entity: Business; id: 0x9683b30 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15> ; data: <fault>)
所以是我做了一些寶和
(lldb) po [_currentBusiness objectID]
error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its type is unknown
warning: couldn't get object pointer (substituting NULL): Couldn't load '_cmd' because its type is unknown
Execution was interrupted, reason: Attempted to dereference an invalid pointer..
The process has been returned to the state before execution.
這就好像_currentBusiness的內容發生了變化。 current_Business仍然存在。它仍然有相同的地址。
這到底是怎麼回事?
不,這不僅僅是錯誤。這是一個不能脫身的錯。
所以我添加進一步絆
-(Business *) currentBusiness
{
if ([[NSThread currentThread] isMainThread])
{
DLog(@"I am a main thread");
}
else
{
assert (false);
DLog(@"I am not a main thread");
}
CLog(@"_currentBusiness %@ withObjectID: %@", _currentBusiness, _currentBusiness.objectID); //add ObjectID
if (IsEmpty(_currentBusiness))
{
//assert(false);
}
if (_currentBusiness.isFault)
{
CLog(@"_currentBusiness.Title %@", _currentBusiness.Title); //Try to unfault
assert(false);
}
return _currentBusiness;
}
我敢打賭,我不能unfault。
所以這就是結果:
2012-05-21 16:08:37.950 BadgerNew[2625:17003] <0x9510470 UtilitiesQuick.m:(69)> _currentBusiness <Business: 0x9589410> (entity: Business; id: 0x95889d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15> ; data: {
Aliases = "<relationship fault: 0x953cdf0 'Aliases'>";
Bookmark = 0;
Building = "0x95889d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15>";
City = "0x958dde0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/City/p2>";
Distance = "689.0068307560858";
DistanceGrouping = "0x9582f40 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/DistanceGrouping/p924>";
Districts = (
"0x874b0d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/District/p4>"
);
Email = nil;
ID = "universitas-indonusa-esa-unggul__-6.19_106.78";
Images = (
"0x95c4be0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Image/p20>"
);
InBuildingAddress = nil;
LatitudeLongitude = "0x958f430 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/LatitudeLongitude/p15>";
Like = 0;
OpeningHour = nil;
PeopleCount = 295;
Phones = (
"0x9237680 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Phone/p4>"
);
Price = 0;
Promotions = "<relationship fault: 0x954bae0 'Promotions'>";
Rating = "0x9584b50 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Rating/p15>";
RatingGroup = "0x9586970 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/RatingGroup/p15>";
Reviews = (
);
Street = "Jl. Arjuna Utara";
Tags = (
"0x8769120 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Tag/p12>"
);
Tenants = "<relationship fault: 0x955fd90 'Tenants'>";
TimeStamp = nil;
Title = "Universitas Indonusa Esa Unggul";
URLs = "<relationship fault: 0x955f620 'URLs'>";
Website = nil;
Zip = 11510;
checkIn = nil;
pinAndLineNumber = 2;
timeLike = nil;
updated = 1;
}) withObjectID: 0x95889d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15>
然後
2012-05-21 16:08:42.797 BadgerNew[2625:17003] <0x9510470 UtilitiesQuick.m:(69)> _currentBusiness <Business: 0x9589410> (entity: Business; id: 0x95889d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15> ; data: <fault>) withObjectID: 0x95889d0 <x-coredata://3993C454-9EE9-4EDC-B1FD-7073A9CEC194/Business/p15>
2012-05-21 16:08:42.797 BadgerNew[2625:17003] <0x9510470 UtilitiesQuick.m:(77)> _currentBusiness.Title (null)
(lldb) po [_currentBusiness objectID]
error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its type is unknown
warning: couldn't get object pointer (substituting NULL): Couldn't load '_cmd' because its type is unknown
Execution was interrupted, reason: Attempted to dereference an invalid pointer..
The process has been returned to the state before execution.
所以_currentBusiness的地址不會改變。 objectID不會更改。不知何故,它成爲過錯。此外,調用_currentBusiness.Title結果(空)
這似乎沒有發生ARC更新之前,雖然我不知道ARC是否導致它。