Can I construct a feasible stream cipher out of HMAC and a secure hash algorithm?
Here is your algorithm in formula form, which might be easier to understand for non-objective-C-experts:

Encryption:


$P_1 \mathbin\Vert P_2 \mathbin\Vert \dots \mathbin\Vert P_n := P$ (split plaintext in blocks, same size as hash output, except the last one)
$K := \operatorname{SHA256}(\mathit{key})$
$O_0 := \mathit{IV} (= K)$
$O_i := \operatorname{HMAC}_{\operatorname{SHA256}}(K, O_{i-1})$ for all $i \in \{ 1, \dots, n\}$ (key stream)
$C_i := P_i \oplus O_i$  for all $i \in \{ 1, \dots, n\}$ (the usual stream cipher XOR)
$C := C_1 \mathbin\Vert \dots \mathbin\Vert C_n$


(where the last block $O_n$ is truncated to match the length of $P_n$)

Decryption: same, but with $C_i$ and $P_i$ swapped.


$P_i := C_i \oplus O_i$  for all $i \in \{ 1, \dots, n\}$


As you remarked right, this is output feedback mode (OFB) with HMAC-SHA-512, with the key reused as the IV. (The value you named IV – $K$ here – is actually the effective key, derived by SHA-256 from the original key, the IV is your first segkey, initialized to the same value).

If you use the commented variant with


$O_i := \operatorname{HMAC}_{\operatorname{SHA256}}(K \mathbin\Vert C_{i-1}, O_{i-1})$,


you have some new mode which is like a mixture of cipher feedback mode and output feedback mode, which uses the cipher feedback as part of the key (?). It is not a synchronous stream cipher anymore, as the keystream depends on the previous ciphertext. You can still decrypt it, you just have to use the previous version of segment instead of the previous version of last as input in the decryption function (i.e. you need one more variable in your program).

If you want to stay with established modes of operation, here is cipher feedback mode (CFB):


$O_i := \operatorname{HMAC}_{\operatorname{SHA256}}(K, C_{i-1})$


This is Counter mode (CTR):


$O_i := \operatorname{HMAC}_{\operatorname{SHA256}}(K, i)$


The analogons to ECB, CBC, PCBC don't work with a MAC (or other PRF like a keyed hash), as there is no inverse which would be needed for decryption.

Also, as Ivella remarked, your stream cipher is a lot slower than dedicated stream ciphers, or the same modes applied to a block cipher.