> On Oct 15, 2015, at 20:52, Ken Thomases <[email protected]> wrote:
>
> On Oct 15, 2015, at 7:33 PM, Alex Hall <[email protected]
> <mailto:[email protected]>> wrote:
>>
>>
>>> On Oct 15, 2015, at 20:06, Jens Alfke <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>>
>>>> On Oct 15, 2015, at 5:03 PM, Alex Hall <[email protected]
>>>> <mailto:[email protected]>> wrote:
>>>>
>>>> I'm sorry to be asking such basic questions, but what do you mean by the
>>>> debug console? The place where errors and print/log statements appear
>>>> doesn't take input
>>>
>>> Yes, it does. When the app is paused, an “(lldb)” prompt appears in that
>>> console and you can type LLDB commands to it followed by Return, like in a
>>> terminal window.
>>
>> Whoa, what do you know, it does! I always figured the LLDB was just letting
>> me know the app was running, I never imagined it was a command prompt.
>> That's really cool. Okay, here's the result of that command (it's quite
>> long):
>>
>> bt
>> * thread #1: tid = 0xda2e6, 0x0000000100491ccf
>> libswiftCore.dylib`swift_slowAlloc + 31, queue = 'com.apple.main-thread',
>> stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
>> * frame #0: 0x0000000100491ccf libswiftCore.dylib`swift_slowAlloc + 31
>> frame #1: 0x0000000100483fa4
>> libswiftCore.dylib`_swift_allocObject_(swift::HeapMetadata const*, unsigned
>> long, unsigned long) + 20
>> frame #2: 0x0000000100273faa
>> libswiftCore.dylib`Swift._ContiguousArrayBuffer.init <A>
>> (Swift._ContiguousArrayBuffer<A>.Type)(count : Swift.Int, minimumCapacity :
>> Swift.Int) -> Swift._ContiguousArrayBuffer<A> + 74
>> frame #3: 0x00000001002809e3
>> libswiftCore.dylib`Swift._forceCreateUniqueMutableBufferForceGrow <A where
>> A: Swift._ArrayBufferType> (inout A, Swift.Int, Swift.Int) ->
>> Swift._ContiguousArrayBuffer<A.Element> + 195
>> frame #4: 0x000000010029675b
>> libswiftCore.dylib`Swift.Array._copyToNewGrownBuffer <A> (inout
>> Swift.Array<A>)(Swift.Int) -> () + 539
>> frame #5: 0x000000010029793f libswiftCore.dylib`Swift.Array.append <A>
>> (inout Swift.Array<A>)(A) -> () + 47
>> frame #6: 0x0000000100019dd3
>> Cinnamon`Cinnamon.TweetsTab.addTweetWithJSONValue (JSONTweet=JSONObject,
>> self=0x00006080000a4380)(SwifterMac.JSON) -> () + 3939 at
>> TweetObjectsModel.swift:262
>
> So the above is the place in your code where you call into Swift's Array
> class in such a way that it provokes the bug. Show us line 262 of
> TweetObjectsModel.swift and the surrounding context.
Line 262:
(Int(newTweetID)! < Int(mostRecentTweetID)! ?
tweetsList.append(newTweet) : tweetsList.insert(newTweet, atIndex:0) )
This function is taking a tweet handed to it by the Swifter library in the form
of a chunk of JSON, creating a new Tweet object from that JSON, then adding the
tweet, in the proper order, to the array 'tweetsList'. Each tab (a tab is a
data structure encapsulating a collection of tweets) calls this function on
itself when it is told to update, if new tweets are found. All tabs are told to
update in viewDidLoad, so this should execute five times, as there are five
tabs by default. The app chokes on the first call to this, so it's not random
or only happening on certain tweets. The full function:
func addTweetWithJSONValue(JSONTweet:JSONValue) {
let newTweet=Tweet(JSONObject:JSONTweet,
isDM:type==TweetsTabTypes.messages)
//if no tweets are yet stored, just add this one
if tweetsList.count==0 {
tweetsList.append(newTweet)
checkForMaxIDUpdateWithNewID(newTweet.idAsString)
checkForSinceIDUpdateWithNewID(newTweet.idAsString)
return
}
let mostRecentTweet=tweetsList[tweetsList.count-1]
if let
mostRecentTweetID=mostRecentTweet.JSONObject["id_str"].string,
newTweetID=newTweet.JSONObject["id_str"].string {
if newTweetID == mostRecentTweetID { //we
already have this tweet, so don't add it again
print("Repeated tweet detected!
Ignoring it and not adding it to the list.")
return
}
//now add the tweet. If the ID is newer, put it
on top, else put it on the bottom.
(Int(newTweetID)! < Int(mostRecentTweetID)! ?
tweetsList.append(newTweet) : tweetsList.insert(newTweet, atIndex:0) )
//offending line
checkForMaxIDUpdateWithNewID(newTweet.idAsString)
checkForSinceIDUpdateWithNewID(newTweet.idAsString)
} else { //ID for this tweet was nil or couldn't be
retrieved
tweetsList.append(newTweet)
print("No ID found while inserting a tweet. It
was appended instead.")
}
}
>
> Regards,
> Ken
>
--
Have a great day,
Alex Hall
[email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com
This email sent to [email protected]